From e85d818b67add3fc3dae0134b6505aa8b6453c67 Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Fri, 3 Feb 2023 17:02:02 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E7=94=A8=E6=88=B7=E5=AE=9E?= =?UTF-8?q?=E4=BD=93=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xkrs/controller/PushController.java | 2 +- .../xkrs/controller/SysUserController.java | 32 ++++++++----------- src/main/java/com/xkrs/dao/SysRoleDao.java | 32 ++++++------------- src/main/java/com/xkrs/dao/SysUserDao.java | 14 ++++---- .../xkrs/model/qo/SysUserPushAccountQo.java | 6 ++-- .../com/xkrs/model/qo/SysUserRemarkQo.java | 6 ++-- .../java/com/xkrs/service/SysUserService.java | 6 ++-- .../xkrs/service/impl/SysUserServiceImpl.java | 7 ++-- 8 files changed, 43 insertions(+), 62 deletions(-) diff --git a/src/main/java/com/xkrs/controller/PushController.java b/src/main/java/com/xkrs/controller/PushController.java index 5f456c3..c032c2f 100644 --- a/src/main/java/com/xkrs/controller/PushController.java +++ b/src/main/java/com/xkrs/controller/PushController.java @@ -31,7 +31,7 @@ public class PushController { @PostMapping("/bindUserPushInfo") public String bindUserPushInfo(@RequestBody SysUserPushAccountQo sysUserPushAccountQo) { - Integer id = sysUserPushAccountQo.getId(); + Long id = sysUserPushAccountQo.getId(); String regID = sysUserPushAccountQo.getRegID(); String userAccount = sysUserPushAccountQo.getUserAccount(); if (null == id) { diff --git a/src/main/java/com/xkrs/controller/SysUserController.java b/src/main/java/com/xkrs/controller/SysUserController.java index 22bdb24..09eae8f 100644 --- a/src/main/java/com/xkrs/controller/SysUserController.java +++ b/src/main/java/com/xkrs/controller/SysUserController.java @@ -88,7 +88,7 @@ public class SysUserController { List failureIdList = new ArrayList<>();//操作失败的ID集合 for (String userId : userIdList) { try { - Optional targetEntityOptional = sysUserDao.findById(Integer.parseInt(userId)); + Optional targetEntityOptional = sysUserDao.findById(Long.parseLong(userId)); if (targetEntityOptional.isPresent()) { SysUserEntity targetEntity = targetEntityOptional.get(); if (!TextUtils.isEmpty(overTime)) { @@ -125,18 +125,16 @@ public class SysUserController { @RequestMapping(value = "/updateviplevel", method = RequestMethod.POST) public String updateVipLevel(@RequestBody SysUserVipLevelQo sysUserVipLevelQo) { String ids = sysUserVipLevelQo.getIds(); - List idList = new ArrayList<>(); + List idList = new ArrayList<>(); if (ids.contains(",")) { String[] splits = ids.split(","); - if (splits != null && splits.length > 0) { - for (String split : splits) { - idList.add(Integer.parseInt(split)); - } + for (String split : splits) { + idList.add(Long.parseLong(split)); } } else { - idList.add(Integer.parseInt(ids)); + idList.add(Long.parseLong(ids)); } - for (Integer id : idList) { + for (Long id : idList) { sysUserDao.updateVipLevel(id, sysUserVipLevelQo.getVipLevel()); } return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale); @@ -149,18 +147,16 @@ public class SysUserController { @RequestMapping(value = "/updatereceivesms", method = RequestMethod.POST) public String updateReceiveSms(@RequestBody SysUserReceiveSmsQo sysUserReceiveSmsQo) { String ids = sysUserReceiveSmsQo.getIds(); - List idList = new ArrayList<>(); + List idList = new ArrayList<>(); if (ids.contains(",")) { String[] splits = ids.split(","); - if (splits != null && splits.length > 0) { - for (String split : splits) { - idList.add(Integer.parseInt(split)); - } + for (String split : splits) { + idList.add(Long.parseLong(split)); } } else { - idList.add(Integer.parseInt(ids)); + idList.add(Long.parseLong(ids)); } - for (Integer id : idList) { + for (Long id : idList) { sysUserDao.updateReceiveSms(id, sysUserReceiveSmsQo.getReceiveSms()); } return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale); @@ -169,7 +165,7 @@ public class SysUserController { @Transactional(rollbackFor = Exception.class) @RequestMapping(value = "/updateremark", method = RequestMethod.POST) public String updateRemark(@RequestBody SysUserRemarkQo sysUserRemarkQo) { - Integer id = sysUserRemarkQo.getId(); + Long id = sysUserRemarkQo.getId(); Optional optionalById = sysUserDao.findById(id); if (optionalById.isEmpty()) { return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL, "修改失败,用户找不到", locale); @@ -231,7 +227,7 @@ public class SysUserController { * 软删除指定id的普通用户 */ @RequestMapping(value = "/general/delete", method = RequestMethod.DELETE) - public String deleteCustomUser(@RequestParam(value = "userId", required = false) int id) { + public String deleteCustomUser(@RequestParam(value = "userId", required = false) Long id) { // 验证数据合法性 int res = sysUserService.softDeleteGeneralUser(id); if (res == 1) { @@ -291,7 +287,7 @@ public class SysUserController { */ @PostMapping("/operateActiveFlag") public String operateActiveFlag(@RequestBody Map map, @RequestHeader(value = "Authorization") String token) { - Integer userId = (Integer) map.get("userId"); + Long userId = (Long) map.get("userId"); String keepType = (String) map.get("keepType"); // 验证token String tokenUserName = TokenUtil.getTokenUserName(token); diff --git a/src/main/java/com/xkrs/dao/SysRoleDao.java b/src/main/java/com/xkrs/dao/SysRoleDao.java index 04e704d..3424eb4 100644 --- a/src/main/java/com/xkrs/dao/SysRoleDao.java +++ b/src/main/java/com/xkrs/dao/SysRoleDao.java @@ -10,51 +10,37 @@ import java.util.List; /** * SysRoleDao + * * @author tajochen */ -public interface SysRoleDao extends JpaRepository { +public interface SysRoleDao extends JpaRepository { /** * 查询用户角色列表根据用户id + * * @param id * @return */ - @Query(value = "SELECT sys_role.id,sys_role.role_name,sys_role.role_name_zh,sys_role.role_desc " + - "FROM sys_role,rel_user_role " + - "WHERE sys_role.id = rel_user_role.role_id " + - "AND rel_user_role.user_id = :id ", nativeQuery = true) - List selectByUserId(@Param("id") Integer id); + @Query(value = "SELECT sys_role.id,sys_role.role_name,sys_role.role_name_zh,sys_role.role_desc FROM sys_role,rel_user_role WHERE sys_role.id = rel_user_role.role_id AND rel_user_role.user_id = :id ", nativeQuery = true) + List selectByUserId(@Param("id") Long id); /** * 查询用户角色列表根据用户名 + * * @param userName * @return */ - @Query(value = "SELECT sys_role.id,sys_role.role_name,sys_role.role_name_zh,sys_role.role_desc " + - "FROM sys_role.ID = rel_user_role.role_id " + - "WHERE rel_user_role.user_id = sys_user.id " + - "AND rel_user_role.user_id = sys_user.id " + - "AND sys_user.user_name = :userName ", nativeQuery = true) + @Query(value = "SELECT sys_role.id,sys_role.role_name,sys_role.role_name_zh,sys_role.role_desc FROM sys_role.ID = rel_user_role.role_id WHERE rel_user_role.user_id = sys_user.id AND rel_user_role.user_id = sys_user.id AND sys_user.user_name = :userName ", nativeQuery = true) List selectByUserName(@Param("userName") String userName); - -// /** -// * 根据用户名修改用户角色 -// */ -// @Modifying -// @Query(value = "UPDATE sys_user SET last_entry_time = now(), last_entry_ip = :ipAddress " + -// "WHERE user_name = :userName ;", nativeQuery = true) -// int updateUserRoleByUserName(@Param("userName") String userName); - /** * 添加用户角色根据用户名和角色名 + * * @param userName * @param roleName * @return */ @Modifying - @Query(value = "INSERT INTO rel_user_role (id,role_id, user_id) " + - "SELECT nextval('rel_user_role_seq'),sys_role.ID,sys_user.ID FROM sys_role,sys_user " + - "WHERE sys_role.role_name = :roleName AND sys_user.user_name = :userName ", nativeQuery = true) + @Query(value = "INSERT INTO rel_user_role (id,role_id, user_id) SELECT nextval('rel_user_role_seq'),sys_role.ID,sys_user.ID FROM sys_role,sys_user WHERE sys_role.role_name = :roleName AND sys_user.user_name = :userName ", nativeQuery = true) int insertRelUserRole(@Param("userName") String userName, @Param("roleName") String roleName); } diff --git a/src/main/java/com/xkrs/dao/SysUserDao.java b/src/main/java/com/xkrs/dao/SysUserDao.java index 8e0519b..0366ad7 100644 --- a/src/main/java/com/xkrs/dao/SysUserDao.java +++ b/src/main/java/com/xkrs/dao/SysUserDao.java @@ -15,19 +15,19 @@ import java.util.List; * * @author tajochen */ -public interface SysUserDao extends JpaRepository, JpaSpecificationExecutor { +public interface SysUserDao extends JpaRepository, JpaSpecificationExecutor { @Modifying(clearAutomatically = true) @Query(value = "UPDATE sys_user SET vip_level = ?2 WHERE id = ?1", nativeQuery = true) - void updateVipLevel(Integer id, Integer vipLevel); + void updateVipLevel(Long id, Integer vipLevel); @Modifying(clearAutomatically = true) @Query(value = "UPDATE sys_user SET receive_sms = ?2 WHERE id = ?1", nativeQuery = true) - void updateReceiveSms(Integer id, Integer receiveSms); + void updateReceiveSms(Long id, Integer receiveSms); @Modifying(clearAutomatically = true) @Query(value = "UPDATE sys_user SET remark = ?2 WHERE id = ?1", nativeQuery = true) - void updateRemark(Integer id, String remark); + void updateRemark(Long id, String remark); /** * 检查系统用户名是否存在 @@ -58,7 +58,7 @@ public interface SysUserDao extends JpaRepository, JpaSp */ @Modifying @Query(value = "UPDATE sys_user SET delete_flag = 1 " + "WHERE id = :id ;", nativeQuery = true) - int softDeleteGeneralUserById(@Param("id") Integer id); + int softDeleteGeneralUserById(@Param("id") Long id); /** * 删除系统用户(危险操作!) @@ -84,14 +84,14 @@ public interface SysUserDao extends JpaRepository, JpaSp */ @Query(value = "update sys_user set active_flag = 0 where id = ?", nativeQuery = true) @Modifying(clearAutomatically = true) - void updateEnable(Integer userId); + void updateEnable(Long userId); /** * 禁用 */ @Query(value = "update sys_user set active_flag = 1 where id = ?", nativeQuery = true) @Modifying(clearAutomatically = true) - void updateDisable(Integer userId); + void updateDisable(Long userId); /** * 用户修改密码 diff --git a/src/main/java/com/xkrs/model/qo/SysUserPushAccountQo.java b/src/main/java/com/xkrs/model/qo/SysUserPushAccountQo.java index a18c68d..33a99d3 100644 --- a/src/main/java/com/xkrs/model/qo/SysUserPushAccountQo.java +++ b/src/main/java/com/xkrs/model/qo/SysUserPushAccountQo.java @@ -2,7 +2,7 @@ package com.xkrs.model.qo; public class SysUserPushAccountQo { - private Integer id; + private Long id; private String regID; @@ -11,11 +11,11 @@ public class SysUserPushAccountQo { public SysUserPushAccountQo() { } - public Integer getId() { + public Long getId() { return id; } - public void setId(Integer id) { + public void setId(Long id) { this.id = id; } diff --git a/src/main/java/com/xkrs/model/qo/SysUserRemarkQo.java b/src/main/java/com/xkrs/model/qo/SysUserRemarkQo.java index 0e0e78c..67d181e 100644 --- a/src/main/java/com/xkrs/model/qo/SysUserRemarkQo.java +++ b/src/main/java/com/xkrs/model/qo/SysUserRemarkQo.java @@ -7,7 +7,7 @@ import javax.validation.constraints.NotNull; public class SysUserRemarkQo { @NotNull(message = "{SysUser.id.blank}", groups = {SysUserQoUpdate.class}) - private Integer id; + private Long id; @NotNull(message = "{SysUser.remark.blank}", groups = {SysUserQoUpdate.class}) private String remark; @@ -15,11 +15,11 @@ public class SysUserRemarkQo { public SysUserRemarkQo() { } - public Integer getId() { + public Long getId() { return id; } - public void setId(Integer id) { + public void setId(Long id) { this.id = id; } diff --git a/src/main/java/com/xkrs/service/SysUserService.java b/src/main/java/com/xkrs/service/SysUserService.java index dbf7638..6e3b718 100644 --- a/src/main/java/com/xkrs/service/SysUserService.java +++ b/src/main/java/com/xkrs/service/SysUserService.java @@ -76,7 +76,7 @@ public interface SysUserService { * @param id * @return */ - int softDeleteGeneralUser(Integer id); + int softDeleteGeneralUser(Long id); /** * 查询用户的信息 @@ -90,14 +90,14 @@ public interface SysUserService { * * @param userId */ - void updateEnable(Integer userId); + void updateEnable(Long userId); /** * 禁用 * * @param userId */ - void updateDisable(Integer userId); + void updateDisable(Long userId); /** * 用户修改密码 diff --git a/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java b/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java index 5219b7f..eeff041 100644 --- a/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java @@ -253,10 +253,9 @@ public class SysUserServiceImpl implements SysUserService { */ @Transactional(rollbackFor = Exception.class) @Override - public int softDeleteGeneralUser(Integer id) { + public int softDeleteGeneralUser(Long id) { String adminRole = "role_administor"; String sysRole = "role_system_manager"; - List list = sysRoleDao.selectByUserId(id); if (list.size() > 0) { SysRoleEntity sysRoleEntity = list.get(1); @@ -285,7 +284,7 @@ public class SysUserServiceImpl implements SysUserService { */ @Transactional(rollbackFor = Exception.class) @Override - public void updateEnable(Integer userId) { + public void updateEnable(Long userId) { sysUserDao.updateEnable(userId); } @@ -296,7 +295,7 @@ public class SysUserServiceImpl implements SysUserService { */ @Transactional(rollbackFor = Exception.class) @Override - public void updateDisable(Integer userId) { + public void updateDisable(Long userId) { sysUserDao.updateDisable(userId); }