From 209985cdf0c0151e4825e2f9c8c9f629506d912a Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Fri, 6 May 2022 13:46:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E7=94=A8=E6=88=B7=20=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xkrs/model/entity/SysUserEntity.java | 44 ++-- .../java/com/xkrs/model/qo/SysUserQo.java | 41 ++-- .../xkrs/service/impl/SysUserServiceImpl.java | 192 ++++++++++-------- 3 files changed, 145 insertions(+), 132 deletions(-) diff --git a/src/main/java/com/xkrs/model/entity/SysUserEntity.java b/src/main/java/com/xkrs/model/entity/SysUserEntity.java index f2b7386..4e10fc3 100644 --- a/src/main/java/com/xkrs/model/entity/SysUserEntity.java +++ b/src/main/java/com/xkrs/model/entity/SysUserEntity.java @@ -7,10 +7,11 @@ import java.time.LocalDateTime; /** * SysUser 表实体类 + * * @author tajochen */ @Entity -@Table(name="sys_user") +@Table(name = "sys_user") public class SysUserEntity implements Serializable { /** @@ -18,7 +19,7 @@ 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) + @SequenceGenerator(name = "sys_user_seq_gen", sequenceName = "sys_user_id_seq", allocationSize = 1) private Integer id; /** @@ -54,7 +55,7 @@ public class SysUserEntity implements Serializable { @Column(nullable = false) private Integer activeFlag; - @Column(nullable = false,columnDefinition = "smallint") + @Column(nullable = false, columnDefinition = "smallint") private Integer statusCode; @Column(nullable = false) @@ -81,10 +82,10 @@ public class SysUserEntity implements Serializable { /** * 账号类别 */ - @Column(length = 64,columnDefinition = "varchar(64)") + @Column(length = 64, columnDefinition = "varchar(64)") private String accountType; - @Column(length = 64,columnDefinition = "varchar(64)") + @Column(length = 64, columnDefinition = "varchar(64)") private String countyName; /** @@ -97,6 +98,8 @@ public class SysUserEntity implements Serializable { */ private String loginLastTime; + private Integer street; + public Integer getId() { return id; } @@ -257,29 +260,16 @@ public class SysUserEntity implements Serializable { this.loginLastTime = loginLastTime; } + public Integer getStreet() { + return street; + } + + public void setStreet(Integer street) { + this.street = street; + } + @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 + '\'' + - '}'; + 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 + '\'' + ", street=" + street + '}'; } } diff --git a/src/main/java/com/xkrs/model/qo/SysUserQo.java b/src/main/java/com/xkrs/model/qo/SysUserQo.java index 3128103..37e8e19 100644 --- a/src/main/java/com/xkrs/model/qo/SysUserQo.java +++ b/src/main/java/com/xkrs/model/qo/SysUserQo.java @@ -11,45 +11,39 @@ import javax.validation.constraints.Size; /** * SysUserQo + * * @author tajochen */ public class SysUserQo { - @NotNull( message = "{SysUser.id.blank}",groups={SysUserQoUpdate.class}) + @NotNull(message = "{SysUser.id.blank}", groups = {SysUserQoUpdate.class}) private Integer id; - @NotBlank(message = "{SysUser.userName.blank}",groups={SysUserQoInsert.class}) - @Size(min = 4,max = 16, message = "{SysUser.userName.length.illegal}",groups = {SysUserQoInsert.class, - SysUserQoUpdate.class}) + @NotBlank(message = "{SysUser.userName.blank}", groups = {SysUserQoInsert.class}) @Size(min = 4, max = 16, message = "{SysUser.userName.length.illegal}", groups = {SysUserQoInsert.class, SysUserQoUpdate.class}) /** * regexp = "^([A-Za-z0-9_]+)$" */ - @Pattern(regexp = "^(13[0-9]|14[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9])\\d{8}$",message = "{SysUser.userName.format.illegal}",groups = {SysUserQoInsert.class, - SysUserQoUpdate.class}) + @Pattern(regexp = "^(13[0-9]|14[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9])\\d{8}$", message = "{SysUser.userName.format.illegal}", groups = {SysUserQoInsert.class, SysUserQoUpdate.class}) private String userName; - @Size(max = 32, message = "{SysUser.nickName.length.illegal}",groups = {SysUserQoInsert.class, - SysUserQoUpdate.class}) + @Size(max = 32, message = "{SysUser.nickName.length.illegal}", groups = {SysUserQoInsert.class, SysUserQoUpdate.class}) private String reallyName; - @NotBlank(message = "{SysUser.password.blank}",groups = {SysUserQoInsert.class}) - @Size(min = 6,max = 16, message = "{SysUser.password.length.illegal}",groups = {SysUserQoInsert.class, - SysUserQoUpdate.class}) - @Pattern(regexp = "^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$",message = "{SysUser.password.format.illegal}", - groups = {SysUserQoInsert.class,SysUserQoUpdate.class}) + @NotBlank(message = "{SysUser.password.blank}", groups = {SysUserQoInsert.class}) + @Size(min = 6, max = 16, message = "{SysUser.password.length.illegal}", groups = {SysUserQoInsert.class, SysUserQoUpdate.class}) + @Pattern(regexp = "^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$", message = "{SysUser.password.format.illegal}", groups = {SysUserQoInsert.class, SysUserQoUpdate.class}) private String password; - @Pattern(regexp = "^(13[0-9]|14[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9])\\d{8}$", - message = "{SysUser.telephone.format.illegal}",groups = {SysUserQoInsert.class,SysUserQoUpdate.class}) + @Pattern(regexp = "^(13[0-9]|14[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9])\\d{8}$", message = "{SysUser.telephone.format.illegal}", groups = {SysUserQoInsert.class, SysUserQoUpdate.class}) private String telephone; - @NotNull(message = "{SysUser.statusCode.illegal}",groups={SysUserQoUpdate.class}) - @Range(min=0,max=2,message = "{SysUser.statusCode.illegal}",groups = {SysUserQoInsert.class, SysUserQoUpdate.class}) + @NotNull(message = "{SysUser.statusCode.illegal}", groups = {SysUserQoUpdate.class}) + @Range(min = 0, max = 2, message = "{SysUser.statusCode.illegal}", groups = {SysUserQoInsert.class, SysUserQoUpdate.class}) private Integer statusCode; private String countyCode; - @NotNull(message = "{SysUser.deleteFlag.null}",groups={SysUserQoUpdate.class}) + @NotNull(message = "{SysUser.deleteFlag.null}", groups = {SysUserQoUpdate.class}) private Integer deleteFlag; private Integer roleId; @@ -62,6 +56,9 @@ public class SysUserQo { private String countyName; + @NotNull(message = "{SysUser.street.blank}", groups = {SysUserQoUpdate.class}) + private Integer street; + public Integer getId() { return id; } @@ -165,4 +162,12 @@ public class SysUserQo { public void setCountyName(String countyName) { this.countyName = countyName; } + + public Integer getStreet() { + return street; + } + + public void setStreet(Integer street) { + this.street = street; + } } diff --git a/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java b/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java index 30d51f2..8d25d24 100644 --- a/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java @@ -8,8 +8,7 @@ import com.xkrs.model.vo.SysUserVo; import com.xkrs.service.RedisService; import com.xkrs.service.SysUserService; import com.xkrs.utils.DateTimeUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.http.util.TextUtils; import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.security.crypto.keygen.KeyGenerators; import org.springframework.stereotype.Service; @@ -23,11 +22,11 @@ import java.util.Map; import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; import static com.xkrs.utils.DateTimeUtil.dateTimeToString; -import static com.xkrs.utils.DateTimeUtil.getNowTime; import static com.xkrs.utils.EncryptDecryptUtil.encry256; /** * 系统用户服务实现 + * * @author tajochen */ @Service @@ -59,6 +58,7 @@ public class SysUserServiceImpl implements SysUserService { /** * 检查用户名是否存在 + * * @param userName * @return */ @@ -66,70 +66,75 @@ public class SysUserServiceImpl implements SysUserService { public boolean checkUserName(String userName) { int num = sysUserDao.checkUserName(userName); return (num == 0); - }; + } /** * 新增用户 + * * @param sysUserQo */ - @Transactional(rollbackFor=Exception.class) + @Transactional(rollbackFor = Exception.class) @Override public String addUser(SysUserQo sysUserQo) { // 获取区域信息 Locale locale = LocaleContextHolder.getLocale(); String salt = KeyGenerators.string().generateKey(); SysUserEntity sysUserEntity = new SysUserEntity(); + sysUserEntity.setStreet(0); sysUserEntity.setUserName(sysUserQo.getUserName()); String o = (String) redisService.get(sysUserQo.getUserName()); - if("".equals(o) || o == null){ - return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"请先发送验证码!",locale); + if ("".equals(o) || o == null) { + return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "请先发送验证码!", locale); } - if(!redisService.get(sysUserQo.getUserName()).equals(sysUserQo.getVerificationCode())){ - return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"验证码错误,请重新输入!",locale); + if (!redisService.get(sysUserQo.getUserName()).equals(sysUserQo.getVerificationCode())) { + return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "验证码错误,请重新输入!", locale); } - if("".equals(sysUserQo.getReallyName()) || sysUserQo.getReallyName() == null){ - return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"真实姓名不能为空!",locale); + if ("".equals(sysUserQo.getReallyName()) || sysUserQo.getReallyName() == null) { + return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "真实姓名不能为空!", locale); } sysUserEntity.setReallyName(sysUserQo.getReallyName()); sysUserEntity.setSalt(salt); sysUserEntity.setPassword(encry256(sysUserQo.getPassword() + salt)); sysUserEntity.setTelephone(sysUserQo.getUserName()); - sysUserEntity.setCountyCode(sysUserQo.getCountyCode()); - if("".equals(sysUserQo.getCountyName()) || sysUserQo.getCountyName() == null){ - return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"省市区名称不能为空!",locale); + if (TextUtils.isEmpty(sysUserQo.getCountyName())) { + return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "省市区街道名称不能为空!", locale); } + sysUserEntity.setCountyCode(sysUserQo.getCountyCode()); - if("0000".equals(sysUserQo.getCountyCode().substring(2))){ + if (1 == sysUserQo.getStreet()) { + sysUserEntity.setActiveFlag(0); + sysUserEntity.setAccountType("街道级"); + } else if ("0000".equals(sysUserQo.getCountyCode().substring(2))) { List byProCode = cityDao.findByProCode(sysUserQo.getCountyCode()); - if(byProCode == null || byProCode.size() == 0){ - return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"省编码不存在!",locale); + if (byProCode == null || byProCode.size() == 0) { + return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "省编码不存在!", locale); } List byProName = cityDao.findByProName(sysUserQo.getCountyName()); - if(byProName == null || byProName.size() == 0){ - return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"您所选择的区域不存在!",locale); + if (byProName == null || byProName.size() == 0) { + return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "您所选择的区域不存在!", locale); } sysUserEntity.setActiveFlag(1); sysUserEntity.setAccountType("省级"); - }else if("00".equals(sysUserQo.getCountyCode().substring(4)) && !"0000".equals(sysUserQo.getCountyCode().substring(2))){ + } else if ("00".equals(sysUserQo.getCountyCode().substring(4)) && !"0000".equals(sysUserQo.getCountyCode().substring(2))) { List byCityCode = countyDao.findByCityCode(sysUserQo.getCountyCode()); - if(byCityCode == null || byCityCode.size() == 0){ - return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"市编码不存在!",locale); + if (byCityCode == null || byCityCode.size() == 0) { + return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "市编码不存在!", locale); } List byCityName = countyDao.findByCityName(sysUserQo.getCountyName()); - if(byCityName == null || byCityName.size() == 0){ - return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"您所选择的区域不存在!",locale); + if (byCityName == null || byCityName.size() == 0) { + return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "您所选择的区域不存在!", locale); } sysUserEntity.setActiveFlag(1); sysUserEntity.setAccountType("市级"); - }else { + } else { CountyEntity byCountyCode = countyDao.findByCountyCode(sysUserQo.getCountyCode()); - if(byCountyCode == null){ - return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"编码不存在!",locale); + if (byCountyCode == null) { + return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "编码不存在!", locale); } CountyEntity byCountyName = countyDao.findByCountyName(sysUserQo.getCountyName()); - if(byCountyName == null){ - return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"您所选择的区域不存在!",locale); + if (byCountyName == null) { + return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "您所选择的区域不存在!", locale); } sysUserEntity.setActiveFlag(0); sysUserEntity.setAccountType("县级"); @@ -142,7 +147,6 @@ public class SysUserServiceImpl implements SysUserService { sysUserEntity.setOverTime(string); sysUserEntity.setLoginNum(0); sysUserEntity.setCountyName(sysUserQo.getCountyName()); - sysUserDao.save(sysUserEntity); RelUserRoleEntity relUserRoleEntity = new RelUserRoleEntity(); @@ -156,11 +160,12 @@ public class SysUserServiceImpl implements SysUserService { relUserRoleDao.save(relUserRoleEntity); relRoleAuthorityDao.save(relRoleAuthorityEntity); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"注册成功!",locale); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "注册成功!", locale); } /** * 查询所有用户Vo + * * @return */ /*@Transactional(rollbackFor=Exception.class) @@ -169,48 +174,49 @@ public class SysUserServiceImpl implements SysUserService { Iterable ls = sysUserDao.selectAllSysUser(); return ls; }*/ - - @Transactional(rollbackFor=Exception.class) + @Transactional(rollbackFor = Exception.class) @Override public SysUserEntity getSysUserByUserName(String userName) { return sysUserDao.selectByUserName(userName); } - @Transactional(rollbackFor=Exception.class) + @Transactional(rollbackFor = Exception.class) @Override - public int updateSysUserLogin(String userName,String ipAddress) { - return sysUserDao.updateSysUserLogin(userName,ipAddress); + public int updateSysUserLogin(String userName, String ipAddress) { + return sysUserDao.updateSysUserLogin(userName, ipAddress); } /** * 更新用户 + * * @param sysUserQo * @return */ - @Transactional(rollbackFor=Exception.class) + @Transactional(rollbackFor = Exception.class) @Override public int updateSysUser(SysUserQo sysUserQo) { SysUserEntity sysUserEntity = new SysUserEntity(); sysUserEntity.setReallyName(sysUserQo.getReallyName()); sysUserDao.save(sysUserEntity); - return 1; + return 1; } /** * 软删除普通用户 + * * @param id * @return */ - @Transactional(rollbackFor=Exception.class) + @Transactional(rollbackFor = Exception.class) @Override public int softDeleteGeneralUser(Integer id) { String adminRole = "role_administor"; - String sysRole ="role_system_manager"; + String sysRole = "role_system_manager"; - List list = sysRoleDao.selectByUserId(id); - if(list.size()>0){ + List list = sysRoleDao.selectByUserId(id); + if (list.size() > 0) { SysRoleEntity sysRoleEntity = list.get(1); - if(sysRole.equals(sysRoleEntity.getRoleName())||adminRole.equals(sysRoleEntity.getRoleName())){ + if (sysRole.equals(sysRoleEntity.getRoleName()) || adminRole.equals(sysRoleEntity.getRoleName())) { sysUserDao.softDeleteGeneralUserById(id); return 0; } @@ -220,6 +226,7 @@ public class SysUserServiceImpl implements SysUserService { /** * 查询用户的信息 + * * @return */ @Override @@ -229,9 +236,10 @@ public class SysUserServiceImpl implements SysUserService { /** * 启用 + * * @param userId */ - @Transactional(rollbackFor=Exception.class) + @Transactional(rollbackFor = Exception.class) @Override public void updateEnable(Integer userId) { sysUserDao.updateEnable(userId); @@ -239,9 +247,10 @@ public class SysUserServiceImpl implements SysUserService { /** * 禁用 + * * @param userId */ - @Transactional(rollbackFor=Exception.class) + @Transactional(rollbackFor = Exception.class) @Override public void updateDisable(Integer userId) { sysUserDao.updateDisable(userId); @@ -249,46 +258,48 @@ public class SysUserServiceImpl implements SysUserService { /** * 用户修改密码 + * * @param oldPassword * @param newPassword * @param confirmPassword * @param sysUserEntity * @return */ - @Transactional(rollbackFor=Exception.class) + @Transactional(rollbackFor = Exception.class) @Override public String updatePassword(String oldPassword, String newPassword, String confirmPassword, SysUserEntity sysUserEntity) { Locale locale = LocaleContextHolder.getLocale(); String oldFrontPassword = encry256(oldPassword + sysUserEntity.getSalt()); - if(!oldFrontPassword.equals(sysUserEntity.getPassword())){ - return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"旧密码输入错误",locale); + if (!oldFrontPassword.equals(sysUserEntity.getPassword())) { + return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "旧密码输入错误", locale); } - if(!newPassword.equals(confirmPassword)){ - return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"两次密码输入不一致",locale); + if (!newPassword.equals(confirmPassword)) { + return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "两次密码输入不一致", locale); } String newAfterPassword = encry256(newPassword + sysUserEntity.getSalt()); - sysUserDao.updatePassword(sysUserEntity.getId(),newAfterPassword); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"密码修改成功",locale); + sysUserDao.updatePassword(sysUserEntity.getId(), newAfterPassword); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "密码修改成功", locale); } /** * 管理员修改用户的密码 + * * @param userId * @param newPassword * @param confirmPassword * @return */ - @Transactional(rollbackFor=Exception.class) + @Transactional(rollbackFor = Exception.class) @Override public String adminUpdatePassword(Integer userId, String newPassword, String confirmPassword) { Locale locale = LocaleContextHolder.getLocale(); - if(!newPassword.equals(confirmPassword)){ - return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"两次密码输入不一致",locale); + if (!newPassword.equals(confirmPassword)) { + return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "两次密码输入不一致", locale); } SysUserEntity sysUserEntity = sysUserDao.selectByUserId(userId); String newAfterPassword = encry256(newPassword + sysUserEntity.getSalt()); - sysUserDao.updatePassword(userId,newAfterPassword); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"密码修改成功",locale); + sysUserDao.updatePassword(userId, newAfterPassword); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "密码修改成功", locale); } @Override @@ -298,132 +309,139 @@ public class SysUserServiceImpl implements SysUserService { /** * 按天数修改账号到期时间 + * * @param userId * @param dayNum * @return */ - @Transactional(rollbackFor=Exception.class) + @Transactional(rollbackFor = Exception.class) @Override public String updateExpireDateDay(Integer userId, Integer dayNum) { Locale locale = LocaleContextHolder.getLocale(); long l = dayNum.longValue(); LocalDateTime now = LocalDateTime.now(); SysUserEntity sysUserEntity = sysUserDao.selectByUserId(userId); - if(DateTimeUtil.dateTimeToString(now).compareTo(sysUserEntity.getOverTime()) > 0){ + if (DateTimeUtil.dateTimeToString(now).compareTo(sysUserEntity.getOverTime()) > 0) { LocalDateTime localDateTime = now.plusDays(l); String time = dateTimeToString(localDateTime); - sysUserDao.updateOverTime(userId,time); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"修改成功",locale); - }else { + sysUserDao.updateOverTime(userId, time); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale); + } else { LocalDateTime localDateTime = DateTimeUtil.stringToDateTime(sysUserEntity.getOverTime()); LocalDateTime localDateTime1 = localDateTime.plusDays(l); String time = dateTimeToString(localDateTime1); - sysUserDao.updateOverTime(userId,time); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"修改成功",locale); + sysUserDao.updateOverTime(userId, time); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale); } } /** * 按月份修改账号过期时间 + * * @param userId * @param dayNum * @return */ - @Transactional(rollbackFor=Exception.class) + @Transactional(rollbackFor = Exception.class) @Override public String updateExpireDateMonth(Integer userId, Integer dayNum) { Locale locale = LocaleContextHolder.getLocale(); long l = dayNum.longValue(); LocalDateTime now = LocalDateTime.now(); SysUserEntity sysUserEntity = sysUserDao.selectByUserId(userId); - if(DateTimeUtil.dateTimeToString(now).compareTo(sysUserEntity.getOverTime()) > 0){ + if (DateTimeUtil.dateTimeToString(now).compareTo(sysUserEntity.getOverTime()) > 0) { LocalDateTime localDateTime = now.plusMonths(l); String time = dateTimeToString(localDateTime); - sysUserDao.updateOverTime(userId,time); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"修改成功",locale); - }else { + sysUserDao.updateOverTime(userId, time); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale); + } else { LocalDateTime localDateTime = DateTimeUtil.stringToDateTime(sysUserEntity.getOverTime()); LocalDateTime localDateTime1 = localDateTime.plusMonths(l); String time = dateTimeToString(localDateTime1); - sysUserDao.updateOverTime(userId,time); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"修改成功",locale); + sysUserDao.updateOverTime(userId, time); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale); } } /** * 按年份修改账号到期时间 + * * @param userId * @param dayNum * @return */ - @Transactional(rollbackFor=Exception.class) + @Transactional(rollbackFor = Exception.class) @Override public String updateExpireDateYear(Integer userId, Integer dayNum) { Locale locale = LocaleContextHolder.getLocale(); long l = dayNum.longValue(); LocalDateTime now = LocalDateTime.now(); SysUserEntity sysUserEntity = sysUserDao.selectByUserId(userId); - if(DateTimeUtil.dateTimeToString(now).compareTo(sysUserEntity.getOverTime()) > 0){ + if (DateTimeUtil.dateTimeToString(now).compareTo(sysUserEntity.getOverTime()) > 0) { LocalDateTime localDateTime = now.plusYears(l); String time = dateTimeToString(localDateTime); - sysUserDao.updateOverTime(userId,time); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"修改成功",locale); - }else { + sysUserDao.updateOverTime(userId, time); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale); + } else { LocalDateTime localDateTime = DateTimeUtil.stringToDateTime(sysUserEntity.getOverTime()); LocalDateTime localDateTime1 = localDateTime.plusYears(l); String time = dateTimeToString(localDateTime1); - sysUserDao.updateOverTime(userId,time); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"修改成功",locale); + sysUserDao.updateOverTime(userId, time); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale); } } /** * 设置账号永久有效 + * * @param userId * @return */ - @Transactional(rollbackFor=Exception.class) + @Transactional(rollbackFor = Exception.class) @Override public String updatePermanent(Integer userId) { Locale locale = LocaleContextHolder.getLocale(); sysUserDao.updateDayNum(userId); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"修改成功",locale); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale); } /** * 修改账号到期时间 + * * @param userId * @param overTime * @return */ - @Transactional(rollbackFor=Exception.class) + @Transactional(rollbackFor = Exception.class) @Override public String updateOverTime(Integer userId, String overTime) { Locale locale = LocaleContextHolder.getLocale(); - sysUserDao.updateOverTime(userId,overTime); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"修改成功",locale); + sysUserDao.updateOverTime(userId, overTime); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale); } /** * 记录用户登录次数 + * * @param userId * @param loginNum */ - @Transactional(rollbackFor=Exception.class) + @Transactional(rollbackFor = Exception.class) @Override public void updateLoginNum(Integer userId, Integer loginNum) { - sysUserDao.updateLoginNum(userId,loginNum); + sysUserDao.updateLoginNum(userId, loginNum); } /** * 记录用户登录时间 + * * @param userId * @param loginLastTime */ - @Transactional(rollbackFor=Exception.class) + @Transactional(rollbackFor = Exception.class) @Override public void updateLoginLastTime(Integer userId, String loginLastTime) { - sysUserDao.updateLoginLastTime(userId,loginLastTime); + sysUserDao.updateLoginLastTime(userId, loginLastTime); } @Override