From 54faad2d67c3356ad6e4a266f57afc1c6edf03b8 Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Fri, 3 Feb 2023 16:44:58 +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 --- .../xkrs/controller/SysUserController.java | 6 +- .../com/xkrs/dao/RelRoleAuthorityDao.java | 2 +- src/main/java/com/xkrs/dao/SysUserDao.java | 12 ++-- .../model/entity/RelRoleAuthorityEntity.java | 21 +++--- .../com/xkrs/model/entity/SysUserEntity.java | 68 +++++++------------ .../com/xkrs/service/SysAuthorityService.java | 4 +- .../java/com/xkrs/service/SysUserService.java | 16 ++--- .../service/impl/SysAuthorityServiceImpl.java | 7 +- .../xkrs/service/impl/SysUserServiceImpl.java | 19 +++--- 9 files changed, 66 insertions(+), 89 deletions(-) diff --git a/src/main/java/com/xkrs/controller/SysUserController.java b/src/main/java/com/xkrs/controller/SysUserController.java index 14ea613..22bdb24 100644 --- a/src/main/java/com/xkrs/controller/SysUserController.java +++ b/src/main/java/com/xkrs/controller/SysUserController.java @@ -332,7 +332,7 @@ public class SysUserController { @PostMapping("/adminUpdatePassword") public String adminUpdatePassword(@RequestBody Map map, @RequestHeader(value = "Authorization") String token) { // 要修改的用户的id - Integer userId = (Integer) map.get("userId"); + Long userId = (Long) map.get("userId"); String newPassword = (String) map.get("newPassword"); String confirmPassword = (String) map.get("confirmPassword"); // 验证token @@ -416,7 +416,7 @@ public class SysUserController { */ @PostMapping("/updateExpireDate") public String updateExpireDate(@RequestBody Map map, @RequestHeader(value = "Authorization") String token) { - Integer userId = (Integer) map.get("userId"); + Long userId = (Long) map.get("userId"); Integer timeNum = (Integer) map.get("timeNum"); String keepType = (String) map.get("keepType"); if ("1".equals(keepType)) { @@ -435,7 +435,7 @@ public class SysUserController { */ @PostMapping("/updateOverTime") public String updateOverTime(@RequestBody Map map, @RequestHeader(value = "Authorization") String token) { - Integer userId = (Integer) map.get("userId"); + Long userId = (Long) map.get("userId"); String overTime = (String) map.get("overTime"); return sysUserService.updateOverTime(userId, overTime); } diff --git a/src/main/java/com/xkrs/dao/RelRoleAuthorityDao.java b/src/main/java/com/xkrs/dao/RelRoleAuthorityDao.java index 2fdd208..637f0c1 100644 --- a/src/main/java/com/xkrs/dao/RelRoleAuthorityDao.java +++ b/src/main/java/com/xkrs/dao/RelRoleAuthorityDao.java @@ -20,7 +20,7 @@ public interface RelRoleAuthorityDao extends JpaRepository selectAuthorityByUserId(@Param("userId") Integer userId); + List selectAuthorityByUserId(@Param("userId") Long userId); @Query(value = "SELECT * FROM rel_role_authority WHERE authority_id = ?1", nativeQuery = true) List selectByAuthorityId(Integer authorityId); diff --git a/src/main/java/com/xkrs/dao/SysUserDao.java b/src/main/java/com/xkrs/dao/SysUserDao.java index 832c58c..8e0519b 100644 --- a/src/main/java/com/xkrs/dao/SysUserDao.java +++ b/src/main/java/com/xkrs/dao/SysUserDao.java @@ -98,40 +98,40 @@ public interface SysUserDao extends JpaRepository, JpaSp */ @Query(value = "update sys_user set password = ?2 where id = ?1", nativeQuery = true) @Modifying(clearAutomatically = true) - void updatePassword(Integer userId, String newPassword); + void updatePassword(Long userId, String newPassword); /** * 根据id查询用户的信息 */ @Query(value = "select * from sys_user where id = ?", nativeQuery = true) - SysUserEntity selectByUserId(Integer userId); + SysUserEntity selectByUserId(Long userId); /** * 根据id修改账户的到期时间 */ @Query(value = "update sys_user set over_time = ?2 where id = ?1", nativeQuery = true) @Modifying(clearAutomatically = true) - void updateOverTime(Integer userId, String overTime); + void updateOverTime(Long userId, String overTime); /** * 将账户的期限修改为永久有效 */ @Query(value = "update sys_user set over_time = '永久' and day_num = 1 where id = ?", nativeQuery = true) @Modifying(clearAutomatically = true) - void updateDayNum(Integer userId); + void updateDayNum(Long userId); /** * 记录用户登录次数 */ @Query(value = "update sys_user set login_num = ?2 where id = ?1", nativeQuery = true) @Modifying(clearAutomatically = true) - void updateLoginNum(Integer userId, Integer loginNum); + void updateLoginNum(Long userId, Integer loginNum); /** * 修改登陆时间 */ @Query(value = "update sys_user set login_last_time = ?2 where id = ?1", nativeQuery = true) @Modifying(clearAutomatically = true) - void updateLoginLastTime(Integer userId, String loginLastTime); + void updateLoginLastTime(Long userId, String loginLastTime); } diff --git a/src/main/java/com/xkrs/model/entity/RelRoleAuthorityEntity.java b/src/main/java/com/xkrs/model/entity/RelRoleAuthorityEntity.java index 24121c1..78da329 100644 --- a/src/main/java/com/xkrs/model/entity/RelRoleAuthorityEntity.java +++ b/src/main/java/com/xkrs/model/entity/RelRoleAuthorityEntity.java @@ -5,10 +5,11 @@ import java.io.Serializable; /** * RelRoleAuthority 表实体类 + * * @author tajochen */ @Entity -@Table(name="rel_role_authority") +@Table(name = "rel_role_authority") public class RelRoleAuthorityEntity implements Serializable { /** @@ -16,7 +17,7 @@ public class RelRoleAuthorityEntity implements Serializable { */ @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "rel_role_authority_seq_gen") - @SequenceGenerator(name = "rel_role_authority_seq_gen", sequenceName = "rel_role_authority_id_seq",allocationSize = 1) + @SequenceGenerator(name = "rel_role_authority_seq_gen", sequenceName = "rel_role_authority_id_seq", allocationSize = 1) private Integer id; @Column(nullable = false) @@ -25,7 +26,10 @@ public class RelRoleAuthorityEntity implements Serializable { @Column(nullable = false) private Integer authorityId; - private Integer userId; + private Long userId; + + public RelRoleAuthorityEntity() { + } public Integer getId() { return id; @@ -51,21 +55,16 @@ public class RelRoleAuthorityEntity implements Serializable { this.authorityId = authorityId; } - public Integer getUserId() { + public Long getUserId() { return userId; } - public void setUserId(Integer userId) { + public void setUserId(Long userId) { this.userId = userId; } @Override public String toString() { - return "RelRoleAuthorityEntity{" + - "id=" + id + - ", roleId=" + roleId + - ", authorityId=" + authorityId + - ", userId=" + userId + - '}'; + return "RelRoleAuthorityEntity{" + "id=" + id + ", roleId=" + roleId + ", authorityId=" + authorityId + ", userId=" + userId + '}'; } } diff --git a/src/main/java/com/xkrs/model/entity/SysUserEntity.java b/src/main/java/com/xkrs/model/entity/SysUserEntity.java index 59e1b9d..e7b12cf 100644 --- a/src/main/java/com/xkrs/model/entity/SysUserEntity.java +++ b/src/main/java/com/xkrs/model/entity/SysUserEntity.java @@ -2,14 +2,7 @@ package com.xkrs.model.entity; import javax.persistence.*; import java.io.Serializable; -import java.time.LocalDateTime; - -/** - * SysUser 表实体类 - * - * @author tajochen - */ @Entity @Table(name = "sys_user") public class SysUserEntity implements Serializable { @@ -20,60 +13,49 @@ public class SysUserEntity implements Serializable { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sys_user_seq_gen") @SequenceGenerator(name = "sys_user_seq_gen", sequenceName = "sys_user_id_seq", allocationSize = 1) - private Integer id; + private Long id; /** * 用户名 */ - @Column(length = 16, nullable = false, unique = true, columnDefinition = "varchar(16)") + @Column(nullable = false, unique = true) private String userName; /** * 用户真实姓名 */ - @Column(length = 32, columnDefinition = "varchar(32)") private String reallyName; /** * 密码 */ - @Column(length = 64, nullable = false, columnDefinition = "varchar(64)") + @Column(nullable = false) private String password; - @Column(length = 32, nullable = false, columnDefinition = "varchar(32)") + @Column(nullable = false) private String salt; - @Column(length = 16, unique = true, columnDefinition = "varchar(16)") + @Column(unique = true) private String telephone; - @Column(length = 32, columnDefinition = "varchar(32)") private String countyCode; - @Column(columnDefinition = "varchar(192)") private String signature; @Column(nullable = false) private Integer activeFlag; - @Column(nullable = false, columnDefinition = "smallint") + @Column(nullable = false) private Integer statusCode; @Column(nullable = false) private String addTime; - private LocalDateTime lastEntryTime; - @Column(nullable = false) private Integer deleteFlag; - @Column(columnDefinition = "varchar(64)") private String lastEntryIp; - /** - * 账号的使用天数 - */ - private Integer dayNum; - /** * 账号到期的时间 */ @@ -82,10 +64,8 @@ public class SysUserEntity implements Serializable { /** * 账号类别 */ - @Column(length = 64, columnDefinition = "varchar(64)") private String accountType; - @Column(length = 64, columnDefinition = "varchar(64)") private String countyName; /** @@ -134,14 +114,20 @@ public class SysUserEntity implements Serializable { */ private String pushRegID; + /** + * VIP时间范围列表Json + */ + @Column(columnDefinition = "varchar(10240)") + private String vipTimeRangeJson; + public SysUserEntity() { } - public Integer getId() { + public Long getId() { return id; } - public void setId(Integer id) { + public void setId(Long id) { this.id = id; } @@ -225,14 +211,6 @@ public class SysUserEntity implements Serializable { this.addTime = addTime; } - public LocalDateTime getLastEntryTime() { - return lastEntryTime; - } - - public void setLastEntryTime(LocalDateTime lastEntryTime) { - this.lastEntryTime = lastEntryTime; - } - public Integer getDeleteFlag() { return deleteFlag; } @@ -249,14 +227,6 @@ public class SysUserEntity implements Serializable { this.lastEntryIp = lastEntryIp; } - public Integer getDayNum() { - return dayNum; - } - - public void setDayNum(Integer dayNum) { - this.dayNum = dayNum; - } - public String getOverTime() { return overTime; } @@ -353,8 +323,16 @@ public class SysUserEntity implements Serializable { this.pushRegID = pushRegID; } + public String getVipTimeRangeJson() { + return vipTimeRangeJson; + } + + public void setVipTimeRangeJson(String vipTimeRangeJson) { + this.vipTimeRangeJson = vipTimeRangeJson; + } + @Override public String toString() { - return "SysUserEntity{" + "id=" + id + ", userName='" + userName + '\'' + ", reallyName='" + reallyName + '\'' + ", password='" + password + '\'' + ", salt='" + salt + '\'' + ", telephone='" + telephone + '\'' + ", countyCode='" + countyCode + '\'' + ", signature='" + signature + '\'' + ", activeFlag=" + activeFlag + ", statusCode=" + statusCode + ", addTime='" + addTime + '\'' + ", lastEntryTime=" + lastEntryTime + ", deleteFlag=" + deleteFlag + ", lastEntryIp='" + lastEntryIp + '\'' + ", dayNum=" + dayNum + ", overTime='" + overTime + '\'' + ", accountType='" + accountType + '\'' + ", countyName='" + countyName + '\'' + ", loginNum=" + loginNum + ", loginLastTime='" + loginLastTime + '\'' + ", userAgent='" + userAgent + '\'' + ", vipLevel=" + vipLevel + ", receiveSms=" + receiveSms + ", remark='" + remark + '\'' + ", agentOrgId=" + agentOrgId + ", pushUserAccount='" + pushUserAccount + '\'' + ", pushRegID='" + pushRegID + '\'' + '}'; + return "SysUserEntity{" + "id=" + id + ", userName='" + userName + '\'' + ", reallyName='" + reallyName + '\'' + ", password='" + password + '\'' + ", salt='" + salt + '\'' + ", telephone='" + telephone + '\'' + ", countyCode='" + countyCode + '\'' + ", signature='" + signature + '\'' + ", activeFlag=" + activeFlag + ", statusCode=" + statusCode + ", addTime='" + addTime + '\'' + ", deleteFlag=" + deleteFlag + ", lastEntryIp='" + lastEntryIp + '\'' + ", overTime='" + overTime + '\'' + ", accountType='" + accountType + '\'' + ", countyName='" + countyName + '\'' + ", loginNum=" + loginNum + ", loginLastTime='" + loginLastTime + '\'' + ", userAgent='" + userAgent + '\'' + ", vipLevel=" + vipLevel + ", receiveSms=" + receiveSms + ", remark='" + remark + '\'' + ", agentOrgId=" + agentOrgId + ", pushUserAccount='" + pushUserAccount + '\'' + ", pushRegID='" + pushRegID + '\'' + ", vipTimeRangeJson='" + vipTimeRangeJson + '\'' + '}'; } } diff --git a/src/main/java/com/xkrs/service/SysAuthorityService.java b/src/main/java/com/xkrs/service/SysAuthorityService.java index 643abbf..7785eca 100644 --- a/src/main/java/com/xkrs/service/SysAuthorityService.java +++ b/src/main/java/com/xkrs/service/SysAuthorityService.java @@ -6,12 +6,14 @@ import java.util.List; /** * 系统权限服务接口 + * * @author tajochen */ public interface SysAuthorityService { /** * 获取权限实体列表根据用户名 + * * @param userName * @return */ @@ -19,5 +21,5 @@ public interface SysAuthorityService { List findAllByIdIn(List id); - List selectAuthorityByUserId(Integer userId); + List selectAuthorityByUserId(Long userId); } diff --git a/src/main/java/com/xkrs/service/SysUserService.java b/src/main/java/com/xkrs/service/SysUserService.java index 7600dc9..dbf7638 100644 --- a/src/main/java/com/xkrs/service/SysUserService.java +++ b/src/main/java/com/xkrs/service/SysUserService.java @@ -118,7 +118,7 @@ public interface SysUserService { * @param confirmPassword * @return */ - String adminUpdatePassword(Integer userId, String newPassword, String confirmPassword); + String adminUpdatePassword(Long userId, String newPassword, String confirmPassword); /** * 获取系统用户实体根据用户名 @@ -135,7 +135,7 @@ public interface SysUserService { * @param dayNum * @return */ - String updateExpireDateDay(Integer userId, Integer dayNum); + String updateExpireDateDay(Long userId, Integer dayNum); /** * 按月份修改账号到期时间 @@ -144,7 +144,7 @@ public interface SysUserService { * @param dayNum * @return */ - String updateExpireDateMonth(Integer userId, Integer dayNum); + String updateExpireDateMonth(Long userId, Integer dayNum); /** * 按年份修改账号到期时间 @@ -153,7 +153,7 @@ public interface SysUserService { * @param dayNum * @return */ - String updateExpireDateYear(Integer userId, Integer dayNum); + String updateExpireDateYear(Long userId, Integer dayNum); /** * 设置账号时间永久有效 @@ -161,7 +161,7 @@ public interface SysUserService { * @param userId * @return */ - String updatePermanent(Integer userId); + String updatePermanent(Long userId); /** * 修改账号到期时间 @@ -170,7 +170,7 @@ public interface SysUserService { * @param overTime * @return */ - String updateOverTime(Integer userId, String overTime); + String updateOverTime(Long userId, String overTime); /** * 记录用户登录次数 @@ -178,7 +178,7 @@ public interface SysUserService { * @param userId * @param loginNum */ - void updateLoginNum(Integer userId, Integer loginNum); + void updateLoginNum(Long userId, Integer loginNum); /** * 记录用户登录时间 @@ -186,6 +186,6 @@ public interface SysUserService { * @param userId * @param loginLastTime */ - void updateLoginLastTime(Integer userId, String loginLastTime); + void updateLoginLastTime(Long userId, String loginLastTime); } diff --git a/src/main/java/com/xkrs/service/impl/SysAuthorityServiceImpl.java b/src/main/java/com/xkrs/service/impl/SysAuthorityServiceImpl.java index 84e7088..34c74bf 100644 --- a/src/main/java/com/xkrs/service/impl/SysAuthorityServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/SysAuthorityServiceImpl.java @@ -4,8 +4,6 @@ import com.xkrs.dao.RelRoleAuthorityDao; import com.xkrs.dao.SysAuthorityDao; import com.xkrs.model.entity.SysAuthorityEntity; import com.xkrs.service.SysAuthorityService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -13,6 +11,7 @@ import java.util.List; /** * 系统权限服务实现 + * * @author tajochen */ @Service @@ -26,7 +25,7 @@ public class SysAuthorityServiceImpl implements SysAuthorityService { @Override public List getSysAuthorityListByUserName(String userName) { - return sysAuthorityDao.selectByUserName(userName); + return sysAuthorityDao.selectByUserName(userName); } @Override @@ -35,7 +34,7 @@ public class SysAuthorityServiceImpl implements SysAuthorityService { } @Override - public List selectAuthorityByUserId(Integer userId) { + public List selectAuthorityByUserId(Long userId) { return relRoleAuthorityDao.selectAuthorityByUserId(userId); } } diff --git a/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java b/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java index 9aa72a7..5219b7f 100644 --- a/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java @@ -185,7 +185,6 @@ public class SysUserServiceImpl implements SysUserService { sysUserEntity.setStatusCode(0); sysUserEntity.setAddTime(dateTimeToString(LocalDateTime.now())); sysUserEntity.setDeleteFlag(0); - sysUserEntity.setDayNum(7); sysUserEntity.setLoginNum(0); sysUserEntity.setCountyCode(countyCode); sysUserEntity.setCountyName(countyName); @@ -196,7 +195,7 @@ public class SysUserServiceImpl implements SysUserService { sysUserDao.save(sysUserEntity); RelUserRoleEntity relUserRoleEntity = new RelUserRoleEntity(); - relUserRoleEntity.setUserId(sysUserEntity.getId().longValue()); + relUserRoleEntity.setUserId(sysUserEntity.getId()); relUserRoleEntity.setRoleId(2); RelRoleAuthorityEntity relRoleAuthorityEntity = new RelRoleAuthorityEntity(); @@ -335,7 +334,7 @@ public class SysUserServiceImpl implements SysUserService { */ @Transactional(rollbackFor = Exception.class) @Override - public String adminUpdatePassword(Integer userId, String newPassword, String confirmPassword) { + public String adminUpdatePassword(Long userId, String newPassword, String confirmPassword) { if (!newPassword.equals(confirmPassword)) { return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "两次密码输入不一致", locale); } @@ -359,7 +358,7 @@ public class SysUserServiceImpl implements SysUserService { */ @Transactional(rollbackFor = Exception.class) @Override - public String updateExpireDateDay(Integer userId, Integer dayNum) { + public String updateExpireDateDay(Long userId, Integer dayNum) { long l = dayNum.longValue(); LocalDateTime now = LocalDateTime.now(); SysUserEntity sysUserEntity = sysUserDao.selectByUserId(userId); @@ -386,7 +385,7 @@ public class SysUserServiceImpl implements SysUserService { */ @Transactional(rollbackFor = Exception.class) @Override - public String updateExpireDateMonth(Integer userId, Integer dayNum) { + public String updateExpireDateMonth(Long userId, Integer dayNum) { long l = dayNum.longValue(); LocalDateTime now = LocalDateTime.now(); SysUserEntity sysUserEntity = sysUserDao.selectByUserId(userId); @@ -413,7 +412,7 @@ public class SysUserServiceImpl implements SysUserService { */ @Transactional(rollbackFor = Exception.class) @Override - public String updateExpireDateYear(Integer userId, Integer dayNum) { + public String updateExpireDateYear(Long userId, Integer dayNum) { long l = dayNum.longValue(); LocalDateTime now = LocalDateTime.now(); SysUserEntity sysUserEntity = sysUserDao.selectByUserId(userId); @@ -439,7 +438,7 @@ public class SysUserServiceImpl implements SysUserService { */ @Transactional(rollbackFor = Exception.class) @Override - public String updatePermanent(Integer userId) { + public String updatePermanent(Long userId) { sysUserDao.updateDayNum(userId); return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale); } @@ -453,7 +452,7 @@ public class SysUserServiceImpl implements SysUserService { */ @Transactional(rollbackFor = Exception.class) @Override - public String updateOverTime(Integer userId, String overTime) { + public String updateOverTime(Long userId, String overTime) { sysUserDao.updateOverTime(userId, overTime); return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale); } @@ -466,7 +465,7 @@ public class SysUserServiceImpl implements SysUserService { */ @Transactional(rollbackFor = Exception.class) @Override - public void updateLoginNum(Integer userId, Integer loginNum) { + public void updateLoginNum(Long userId, Integer loginNum) { sysUserDao.updateLoginNum(userId, loginNum); } @@ -478,7 +477,7 @@ public class SysUserServiceImpl implements SysUserService { */ @Transactional(rollbackFor = Exception.class) @Override - public void updateLoginLastTime(Integer userId, String loginLastTime) { + public void updateLoginLastTime(Long userId, String loginLastTime) { sysUserDao.updateLoginLastTime(userId, loginLastTime); }