返回cate和list数量

This commit is contained in:
Zhang Liguo 2023-12-25 14:17:18 +08:00
parent 0f2a954882
commit a2fe05df1d
20 changed files with 158 additions and 40 deletions

View File

@ -8,6 +8,7 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
@RestController @RestController
@ -20,9 +21,9 @@ public class ConfigController {
@RequestMapping("/updateConfig") @RequestMapping("/updateConfig")
public String updateConfig(Config config){ public String updateConfig(Config config){
Date date=new Date(); Date date=new Date();
int date1=Integer.valueOf(date.toString()); try {
config.setUpdatetime(date1); config.setUpdatetime(date.getTime());
if (config==null){ if (config.getName().equals("")||config.getValue().equals("")){
return "配置文件不能为空!"; return "配置文件不能为空!";
} }
if (configService.updateConfig(config)==1){ if (configService.updateConfig(config)==1){
@ -32,18 +33,24 @@ public class ConfigController {
else if (configService.updateConfig(config)==2){ else if (configService.updateConfig(config)==2){
return "不存在名称为"+config.getName()+"的配置文件,请先添加!"; return "不存在名称为"+config.getName()+"的配置文件,请先添加!";
} }
return "更新失败!"; return "更新失败!";}catch (NullPointerException e){
return "请输入配置信息!";
}
} }
@RequestMapping("/addConfigString") @RequestMapping("/addConfigString")
public String addConfig(Config config){ public String addConfig(Config config){
if (config.getName()==null||config.getValue()==null){ try {
return "属性值不能为空"; if (config.getName().equals("")||config.getValue().equals("")){
}else { return "属性值不能为空";
Date date=new Date(); }else {
int date1=Integer.valueOf(date.toString()); Date date=new Date();
config.setUpdatetime(date1); config.setUpdatetime(date.getTime());
return configService.addConfig(config); return configService.addConfig(config);
}
}catch (NullPointerException e){
return "请输入配置信息";
} }
} }
} }

View File

@ -6,6 +6,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
@RestController @RestController
public class NavController { public class NavController {
@Autowired @Autowired
@ -34,7 +36,7 @@ public class NavController {
} }
@RequestMapping("/selectAllNav") @RequestMapping("/selectAllNav")
public String selectAllNav(){ public HashMap<Integer, Object> selectAllNav(){
return navService.selectAllNav(); return navService.selectAllNav();
} }

View File

@ -675,4 +675,5 @@ public class UrlAndCateController {
return JSONObject.toJSONString(result); return JSONObject.toJSONString(result);
} }
} }

View File

@ -9,10 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Date; import java.util.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
@RestController @RestController
public class UrlListController { public class UrlListController {
@ -119,4 +116,19 @@ public class UrlListController {
result.put("data",urlListService.TopEight()); result.put("data",urlListService.TopEight());
return JSONObject.toJSONString(result); return JSONObject.toJSONString(result);
} }
@RequestMapping("/getCateAndListNum")
public HashMap<String,String>getCateAndListNum(UrlCateList urlCateList){
HashMap<String,String>map=new HashMap<>();
if (urlCateList.getUserId()==null){
map.put("msg","用户ID不能为空");
return map;
}
List<Integer> ss=new ArrayList<>();
ss= (List<Integer>) urlCateListService.countAllCateByUser(urlCateList).get("cateNum");
map.put("cateNum", String.valueOf(ss.size()));
map.put("urlListNum", String.valueOf(urlListService.countUrlListByUserId(ss)));
return map;
}
} }

View File

@ -196,4 +196,27 @@ public class UserController {
return userService.getAllUsers(); return userService.getAllUsers();
} }
@RequestMapping("/updateUserDetails")
public String updateUserDetails(User user){
if (user==null){
return "用户不能为空!";
}
return userService.updateUserMessage(user);
}
@RequestMapping("/deleteUser")
public String deleteUser(User user){
if (user==null){
return "请输入删除的用户的信息ID";
}
return userService.deleteUser(user);
}
// @RequestMapping("/updateStatus")
// public String updateStatus(User user){
// if (user==null){
// return "用户不能为空!";
// }
// return userService.updateUserMessage(user);
// }
} }

View File

@ -1,9 +1,11 @@
package com.lovenav.dao; package com.lovenav.dao;
import com.lovenav.entity.Nav; import com.lovenav.entity.Nav;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.HashMap;
import java.util.List; import java.util.List;
@Repository @Repository
@ -22,6 +24,6 @@ public interface NavDao {
int updateByPrimaryKey(Nav record); int updateByPrimaryKey(Nav record);
Nav selectAlreadyExist(Nav nav); Nav selectAlreadyExist(Nav nav);
@MapKey("id")
List<Nav> selectAllNav(); HashMap<Integer,Object> selectAllNav();
} }

View File

@ -2,11 +2,13 @@ package com.lovenav.dao;
import com.lovenav.entity.UrlCateList; import com.lovenav.entity.UrlCateList;
import com.lovenav.entity.UrlList; import com.lovenav.entity.UrlList;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.HashMap;
import java.util.List; import java.util.List;
@Repository @Repository
@ -23,12 +25,12 @@ public interface UrlCateListDao {
int updateByPrimaryKeySelective(UrlCateList record); int updateByPrimaryKeySelective(UrlCateList record);
int updateByPrimaryKey(UrlCateList record); int updateByPrimaryKey(UrlCateList record);
public int countAllCateName(UrlCateList urlCateList);
public List<Integer>selectAllCateByUser(Integer userId);
public UrlCateList selectCateByNameAnduserId(@Param("name")String name, @Param("userId") int userId); public UrlCateList selectCateByNameAnduserId(@Param("name")String name, @Param("userId") int userId);
public List<UrlCateList> selectUrListByUserId(Integer userId); public List<UrlCateList> selectUrListByUserId(Integer userId);
public String selectUrListCateByUrlCateId(Integer cateId); public String selectUrListCateByUrlCateId(Integer cateId);

View File

@ -2,6 +2,7 @@ package com.lovenav.dao;
import com.lovenav.entity.UrlList; import com.lovenav.entity.UrlList;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@ -22,7 +23,7 @@ public interface UrlListDao {
int updateByPrimaryKey(UrlList record); int updateByPrimaryKey(UrlList record);
int countAllUrlList(@Param("cateList") List<Integer>cateList);
public List<UrlList> selectUrList(); public List<UrlList> selectUrList();
public UrlList selectUrListByInput(String input); public UrlList selectUrListByInput(String input);

View File

@ -17,7 +17,11 @@ public class Config implements Serializable {
private String value; private String value;
private Integer updatetime; public void setUpdatetime(Long updatetime) {
this.updatetime = updatetime;
}
private Long updatetime;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -53,11 +57,7 @@ public class Config implements Serializable {
this.value = value; this.value = value;
} }
public Integer getUpdatetime() {
return updatetime;
}
public void setUpdatetime(Integer updatetime) {
this.updatetime = updatetime;
}
} }

View File

@ -2,11 +2,13 @@ package com.lovenav.service;
import com.lovenav.entity.Nav; import com.lovenav.entity.Nav;
import java.util.HashMap;
public interface NavService { public interface NavService {
public String deleteNav(Nav nav); public String deleteNav(Nav nav);
public String updateNav(Nav nav); public String updateNav(Nav nav);
public String selectNav(Nav nav); public String selectNav(Nav nav);
public String addNav(Nav nav); public String addNav(Nav nav);
String selectAllNav(); HashMap<Integer,Object> selectAllNav();
} }

View File

@ -3,6 +3,7 @@ package com.lovenav.service;
import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONArray;
import com.lovenav.entity.UrlCateList; import com.lovenav.entity.UrlCateList;
import java.util.HashMap;
import java.util.List; import java.util.List;
public interface UrlCateListService { public interface UrlCateListService {
@ -25,4 +26,6 @@ public interface UrlCateListService {
public int deleteByPrimaryKey(Integer id); public int deleteByPrimaryKey(Integer id);
public HashMap<String, Object> countAllCateByUser(UrlCateList urlCateList);
} }

View File

@ -12,6 +12,7 @@ public interface UrlListService {
public UrlList selectUrlListByUrlId(Long urlId); public UrlList selectUrlListByUrlId(Long urlId);
public int updateUrlStatusListById(UrlList urlList); public int updateUrlStatusListById(UrlList urlList);
public int countUrlListByUserId(List<Integer>cate);
public List<UrlList> selectUrListByNeedLogin(); public List<UrlList> selectUrListByNeedLogin();
public int insertUrlByUser(UrlList urlList); public int insertUrlByUser(UrlList urlList);

View File

@ -18,4 +18,8 @@ public interface UserService {
HashMap<Integer,Object> getAllUsers(); HashMap<Integer,Object> getAllUsers();
String updateUserMessage(User user);
String deleteUser(User user);
} }

View File

@ -7,6 +7,8 @@ import com.lovenav.service.NavService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.HashMap;
@Service @Service
public class NavServiceImpl implements NavService { public class NavServiceImpl implements NavService {
@Autowired @Autowired
@ -48,6 +50,9 @@ public class NavServiceImpl implements NavService {
if(navDao.selectAlreadyExist(nav)!=null){ if(navDao.selectAlreadyExist(nav)!=null){
return "已经有相同名称的导航!"; return "已经有相同名称的导航!";
} }
if (nav.getStatus()==null){
nav.setStatus(1);
}
result=navDao.insertSelective(nav); result=navDao.insertSelective(nav);
if (result==1){ if (result==1){
return "添加成功"; return "添加成功";
@ -57,7 +62,7 @@ public class NavServiceImpl implements NavService {
} }
@Override @Override
public String selectAllNav() { public HashMap<Integer,Object> selectAllNav() {
return (String) JSON.toJSON(navDao.selectAllNav()); return navDao.selectAllNav();
} }
} }

View File

@ -161,4 +161,12 @@ public class UrlCateListServiceImpl implements UrlCateListService {
public int deleteByPrimaryKey(Integer id){ public int deleteByPrimaryKey(Integer id){
return urlCateListDao.deleteByPrimaryKey(id); return urlCateListDao.deleteByPrimaryKey(id);
} }
@Override
public HashMap<String, Object> countAllCateByUser(UrlCateList urlCateList) {
HashMap<String, Object> map=new HashMap<>();
map.put("cateNum", urlCateListDao.selectAllCateByUser(urlCateList.getUserId()));
return map;
}
} }

View File

@ -86,6 +86,16 @@ public class UrlLiserServiceImpl implements UrlListService {
} }
} }
@Override
public int countUrlListByUserId(List<Integer> cate) {
int num= urlListDao.countAllUrlList(cate);
return num;
}
public int deleteByPrimaryKey(Long id){ public int deleteByPrimaryKey(Long id){
return urlListDao.deleteByPrimaryKey(id); return urlListDao.deleteByPrimaryKey(id);
} }
@ -98,4 +108,7 @@ public class UrlLiserServiceImpl implements UrlListService {
public List<UrlList> TopEight(){return urlListDao.TopEight(); } public List<UrlList> TopEight(){return urlListDao.TopEight(); }
public List<UrlList> latestEight(){return urlListDao.latestEight(); } public List<UrlList> latestEight(){return urlListDao.latestEight(); }
} }

View File

@ -66,6 +66,25 @@ public class UserServiceImpl implements UserService {
return map; return map;
} }
@Override
public String updateUserMessage(User user) {
if(userDao.updateByPrimaryKeySelective(user)==1){
return "更新成功";
}else {
return "更新失败!";
}
}
@Override
public String deleteUser(User user) {
if (userDao.deleteByPrimaryKey(user.getId())==1){
return "删除成功!";
}else {
return "删除失败!";
}
}
@Override @Override
public String sendEmailActivecode(User user, HashMap<String,String>configMap) { public String sendEmailActivecode(User user, HashMap<String,String>configMap) {
return EmailUtils.sendEmail(user,configMap); return EmailUtils.sendEmail(user,configMap);

View File

@ -6,7 +6,7 @@
<result column="type" jdbcType="OTHER" property="type" /> <result column="type" jdbcType="OTHER" property="type" />
<result column="name" jdbcType="VARCHAR" property="name" /> <result column="name" jdbcType="VARCHAR" property="name" />
<result column="value" jdbcType="VARCHAR" property="value" /> <result column="value" jdbcType="VARCHAR" property="value" />
<result column="updatetime" jdbcType="INTEGER" property="updatetime" /> <result column="updatetime" jdbcType="BIGINT" property="updatetime" />
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, `type`, `name`, `value`, updatetime id, `type`, `name`, `value`, updatetime
@ -32,7 +32,7 @@
insert into ln_config (`type`, `name`, `value`, insert into ln_config (`type`, `name`, `value`,
updatetime) updatetime)
values (#{type,jdbcType=OTHER}, #{name,jdbcType=VARCHAR}, #{value,jdbcType=VARCHAR}, values (#{type,jdbcType=OTHER}, #{name,jdbcType=VARCHAR}, #{value,jdbcType=VARCHAR},
#{updatetime,jdbcType=INTEGER}) #{updatetime,jdbcType=BIGINT})
</insert> </insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.lovenav.entity.Config" useGeneratedKeys="true"> <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.lovenav.entity.Config" useGeneratedKeys="true">
insert into ln_config insert into ln_config
@ -61,7 +61,7 @@
#{value,jdbcType=VARCHAR}, #{value,jdbcType=VARCHAR},
</if> </if>
<if test="updatetime != null"> <if test="updatetime != null">
#{updatetime,jdbcType=INTEGER}, #{updatetime,jdbcType=BIGINT},
</if> </if>
</trim> </trim>
</insert> </insert>
@ -78,7 +78,7 @@
`value` = #{value,jdbcType=VARCHAR}, `value` = #{value,jdbcType=VARCHAR},
</if> </if>
<if test="updatetime != null"> <if test="updatetime != null">
updatetime = #{updatetime,jdbcType=INTEGER}, updatetime = #{updatetime,jdbcType=BIGINT},
</if> </if>
</set> </set>
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
@ -88,7 +88,7 @@
set `type` = #{type,jdbcType=OTHER}, set `type` = #{type,jdbcType=OTHER},
`name` = #{name,jdbcType=VARCHAR}, `name` = #{name,jdbcType=VARCHAR},
`value` = #{value,jdbcType=VARCHAR}, `value` = #{value,jdbcType=VARCHAR},
updatetime = #{updatetime,jdbcType=INTEGER} updatetime = #{updatetime,jdbcType=BIGINT}
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</update> </update>
<update id="updateByName" parameterType="com.lovenav.entity.Config"> <update id="updateByName" parameterType="com.lovenav.entity.Config">
@ -101,7 +101,7 @@
`value` = #{value,jdbcType=VARCHAR}, `value` = #{value,jdbcType=VARCHAR},
</if> </if>
<if test="updatetime != null"> <if test="updatetime != null">
updatetime = #{updatetime,jdbcType=INTEGER}, updatetime = #{updatetime,jdbcType=BIGINT},
</if> </if>
</set> </set>
where name = #{name,jdbcType=VARCHAR} where name = #{name,jdbcType=VARCHAR}

View File

@ -63,8 +63,15 @@
(SELECT @pids := #{id ,jdbcType=INTEGER}) t2) t3 (SELECT @pids := #{id ,jdbcType=INTEGER}) t2) t3
WHERE ischild != '0' WHERE ischild != '0'
</select> </select>
<select id="countAllCateName" resultType="java.lang.Integer">
select count(*) from ln_url_cate_list where user_id=#{userId,jdbcType=INTEGER}
</select>
<select id="selectAllCateByUser" resultType="java.lang.Integer" >
select
id
from ln_url_cate_list
where user_id = #{userId,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">

View File

@ -74,7 +74,13 @@
from ln_url_list from ln_url_list
where id = #{urlId,jdbcType=BIGINT} where id = #{urlId,jdbcType=BIGINT}
</select> </select>
<select id="countAllUrlList" resultType="java.lang.Integer" >
select count(*) from ln_url_list
where cate_id in
<foreach collection="cateList" open="(" separator="," close=")" item="cate">
#{cate}
</foreach>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">