From 0a386ed8a29e9bc76a6ef7b57747484e378c6064 Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Mon, 6 Jun 2022 11:45:46 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=A1=A8=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=A4=87=E6=B3=A8=E5=AD=97=E6=AE=B5=EF=BC=8C=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E5=8F=AF=E4=BB=A5=E7=BC=96=E8=BE=91=E5=A4=87=E6=B3=A8?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xkrs/controller/SysUserController.java | 15 +++++++++ src/main/java/com/xkrs/dao/SysUserDao.java | 8 +++-- .../com/xkrs/model/entity/SysUserEntity.java | 15 ++++++++- .../com/xkrs/model/qo/SysUserRemarkQo.java | 33 +++++++++++++++++++ .../java/com/xkrs/model/vo/SysUserVo.java | 14 ++++++-- .../xkrs/service/impl/SysUserServiceImpl.java | 1 + 6 files changed, 81 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/xkrs/model/qo/SysUserRemarkQo.java diff --git a/src/main/java/com/xkrs/controller/SysUserController.java b/src/main/java/com/xkrs/controller/SysUserController.java index 1dafe0c..29b3357 100644 --- a/src/main/java/com/xkrs/controller/SysUserController.java +++ b/src/main/java/com/xkrs/controller/SysUserController.java @@ -8,6 +8,7 @@ import com.xkrs.dao.SysUserDao; import com.xkrs.model.entity.SysUserEntity; import com.xkrs.model.qo.SysUserQo; import com.xkrs.model.qo.SysUserReceiveSmsQo; +import com.xkrs.model.qo.SysUserRemarkQo; import com.xkrs.model.qo.SysUserVipLevelQo; import com.xkrs.model.validation.SysUserQoInsert; import com.xkrs.model.validation.SysUserQoUpdate; @@ -108,6 +109,20 @@ public class SysUserController { return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale); } + @Transactional(rollbackFor = Exception.class) + @RequestMapping(value = "/updateremark", method = RequestMethod.POST) + public String updateRemark(@RequestBody SysUserRemarkQo sysUserRemarkQo) { + // 获取区域信息 + Locale locale = LocaleContextHolder.getLocale(); + Integer id = sysUserRemarkQo.getId(); + Optional optionalById = sysUserDao.findById(id); + if (optionalById.isEmpty()) { + return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL, "修改失败,用户找不到", locale); + } + sysUserDao.updateRemark(id, sysUserRemarkQo.getRemark()); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale); + } + /** * 登录用户Token验证 * diff --git a/src/main/java/com/xkrs/dao/SysUserDao.java b/src/main/java/com/xkrs/dao/SysUserDao.java index 10d8523..1e938e8 100644 --- a/src/main/java/com/xkrs/dao/SysUserDao.java +++ b/src/main/java/com/xkrs/dao/SysUserDao.java @@ -24,6 +24,10 @@ public interface SysUserDao extends JpaRepository { @Query(value = "UPDATE sys_user SET receive_sms = ?2 WHERE id = ?1", nativeQuery = true) void updateReceiveSms(Integer 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); + /** * 检查系统用户名是否存在 * @@ -96,7 +100,7 @@ public interface SysUserDao extends JpaRepository { * * @return */ - @Query(value = "select new com.xkrs.model.vo.SysUserVo (id,reallyName,telephone,countyCode,activeFlag,addTime,overTime,dayNum,accountType,countyName,lastEntryIp,loginNum,loginLastTime,vipLevel,receiveSms) " + "from SysUserEntity") + @Query(value = "select new com.xkrs.model.vo.SysUserVo (id,reallyName,telephone,countyCode,activeFlag,addTime,overTime,dayNum,accountType,countyName,lastEntryIp,loginNum,loginLastTime,vipLevel,receiveSms,remark) " + "from SysUserEntity") List selectAll(); /** @@ -105,7 +109,7 @@ public interface SysUserDao extends JpaRepository { * @param userName * @return */ - @Query(value = "select new com.xkrs.model.vo.SysUserVo (id,reallyName,telephone,countyCode,activeFlag,addTime,overTime,dayNum,accountType,countyName,lastEntryIp,loginNum,loginLastTime,vipLevel,receiveSms) " + "from SysUserEntity where userName = :userName") + @Query(value = "select new com.xkrs.model.vo.SysUserVo (id,reallyName,telephone,countyCode,activeFlag,addTime,overTime,dayNum,accountType,countyName,lastEntryIp,loginNum,loginLastTime,vipLevel,receiveSms,remark) " + "from SysUserEntity where userName = :userName") SysUserVo selectUserByUserName(String userName); /** diff --git a/src/main/java/com/xkrs/model/entity/SysUserEntity.java b/src/main/java/com/xkrs/model/entity/SysUserEntity.java index 7bf94a1..39be374 100644 --- a/src/main/java/com/xkrs/model/entity/SysUserEntity.java +++ b/src/main/java/com/xkrs/model/entity/SysUserEntity.java @@ -114,6 +114,11 @@ public class SysUserEntity implements Serializable { */ private Integer receiveSms; + /** + * 备注 + */ + private String remark; + public SysUserEntity() { } @@ -301,8 +306,16 @@ public class SysUserEntity implements Serializable { this.receiveSms = receiveSms; } + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + @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 + '}'; + 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 + '\'' + '}'; } } diff --git a/src/main/java/com/xkrs/model/qo/SysUserRemarkQo.java b/src/main/java/com/xkrs/model/qo/SysUserRemarkQo.java new file mode 100644 index 0000000..0e0e78c --- /dev/null +++ b/src/main/java/com/xkrs/model/qo/SysUserRemarkQo.java @@ -0,0 +1,33 @@ +package com.xkrs.model.qo; + +import com.xkrs.model.validation.SysUserQoUpdate; + +import javax.validation.constraints.NotNull; + +public class SysUserRemarkQo { + + @NotNull(message = "{SysUser.id.blank}", groups = {SysUserQoUpdate.class}) + private Integer id; + + @NotNull(message = "{SysUser.remark.blank}", groups = {SysUserQoUpdate.class}) + private String remark; + + public SysUserRemarkQo() { + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } +} diff --git a/src/main/java/com/xkrs/model/vo/SysUserVo.java b/src/main/java/com/xkrs/model/vo/SysUserVo.java index a40a90c..4ff3cd8 100644 --- a/src/main/java/com/xkrs/model/vo/SysUserVo.java +++ b/src/main/java/com/xkrs/model/vo/SysUserVo.java @@ -39,7 +39,9 @@ public class SysUserVo implements Serializable { private Integer receiveSms; - public SysUserVo(Integer id, String reallyName, String telephone, String countyCode, Integer activeFlag, String addTime, String overTime, Integer dayNum, String accountType, String countyName, String lastEntryIp, Integer loginNum, String loginLastTime, Integer vipLevel, Integer receiveSms) { + private String remark; + + public SysUserVo(Integer id, String reallyName, String telephone, String countyCode, Integer activeFlag, String addTime, String overTime, Integer dayNum, String accountType, String countyName, String lastEntryIp, Integer loginNum, String loginLastTime, Integer vipLevel, Integer receiveSms, String remark) { this.id = id; this.reallyName = reallyName; this.telephone = telephone; @@ -55,6 +57,7 @@ public class SysUserVo implements Serializable { this.loginLastTime = loginLastTime; this.vipLevel = vipLevel; this.receiveSms = receiveSms; + this.remark = remark; } public Integer getId() { @@ -176,5 +179,12 @@ public class SysUserVo implements Serializable { public void setReceiveSms(Integer receiveSms) { this.receiveSms = receiveSms; } -} + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } +} \ No newline at end of file diff --git a/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java b/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java index 10b4b6c..634e1ca 100644 --- a/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java @@ -169,6 +169,7 @@ public class SysUserServiceImpl implements SysUserService { sysUserEntity.setCountyName(countyName); sysUserEntity.setVipLevel(0); sysUserEntity.setReceiveSms(0); + sysUserEntity.setRemark("");//备注 sysUserDao.save(sysUserEntity); RelUserRoleEntity relUserRoleEntity = new RelUserRoleEntity();