From 8886bb2eb8ff6673f722484a0edb435071f12663 Mon Sep 17 00:00:00 2001 From: "DESKTOP-G8BCEP0\\HP" <2037158277@qq.com> Date: Wed, 22 Sep 2021 17:58:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=86=E7=A0=81=E7=9A=84=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=EF=BC=8C=E6=B7=BB=E5=8A=A0=E4=BA=86=E9=83=A8=E9=97=A8=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E4=BF=A1=E6=81=AF=EF=BC=8C=E4=BF=AE=E6=94=B9=E4=BA=86?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=B7=A5=E6=97=B6=E7=9A=84=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=EF=BC=8C=E5=B0=86=E6=8F=90=E4=BA=A4=E7=9A=84=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=8D=A1=E5=9C=A824=E5=B0=8F=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xkrs/controller/SysUserController.java | 3 ++- src/main/java/com/xkrs/dao/SysUserDao.java | 12 +++++++++++- src/main/java/com/xkrs/service/SysUserService.java | 2 +- .../com/xkrs/service/impl/SysUserServiceImpl.java | 10 +++++----- .../xkrs/service/impl/WorkHourRecordServiceImpl.java | 3 +++ 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/xkrs/controller/SysUserController.java b/src/main/java/com/xkrs/controller/SysUserController.java index 3e1dd8e..2e02ee8 100644 --- a/src/main/java/com/xkrs/controller/SysUserController.java +++ b/src/main/java/com/xkrs/controller/SysUserController.java @@ -223,13 +223,14 @@ public class SysUserController { String oldPassword = (String) map.get("oldPassword"); String newPassword = (String) map.get("newPassword"); String confirmPassword = (String) map.get("confirmPassword"); + String userDepartment = (String) map.get("userDepartment"); // 验证token String tokenUserName = TokenUtil.getTokenUserName(token); SysUserEntity sysUserEntity = sysUserDao.selectByUserName(tokenUserName); if(sysUserEntity == null){ return outputEncapsulationObject(PromptMessageEnum.USER_LOGIN_ERROR,"您还没有注册登录,请先注册登录",locale); } - return sysUserService.updatePassword(oldPassword,newPassword,confirmPassword,sysUserEntity); + return sysUserService.updatePassword(oldPassword,newPassword,confirmPassword,sysUserEntity,userDepartment); } /** diff --git a/src/main/java/com/xkrs/dao/SysUserDao.java b/src/main/java/com/xkrs/dao/SysUserDao.java index 8216e4a..726ac8a 100644 --- a/src/main/java/com/xkrs/dao/SysUserDao.java +++ b/src/main/java/com/xkrs/dao/SysUserDao.java @@ -125,10 +125,20 @@ public interface SysUserDao extends JpaRepository { * 用户修改密码 * @param userId * @param newPassword + * @param userDepartment + */ + @Query(value = "update sys_user set password = ?2, user_department = ?3 where id = ?1",nativeQuery = true) + @Modifying(clearAutomatically=true) + void updatePassword(Integer userId,String newPassword,String userDepartment); + + /** + * 管理员修改用户密码 + * @param userId + * @param newPassword */ @Query(value = "update sys_user set password = ?2 where id = ?1",nativeQuery = true) @Modifying(clearAutomatically=true) - void updatePassword(Integer userId,String newPassword); + void updatePasswords(Integer userId,String newPassword); /** * 根据id查询用户的信息 diff --git a/src/main/java/com/xkrs/service/SysUserService.java b/src/main/java/com/xkrs/service/SysUserService.java index 30d914e..47f2a04 100644 --- a/src/main/java/com/xkrs/service/SysUserService.java +++ b/src/main/java/com/xkrs/service/SysUserService.java @@ -87,7 +87,7 @@ public interface SysUserService { * @param sysUserEntity * @return */ - String updatePassword(String oldPassword,String newPassword,String confirmPassword,SysUserEntity sysUserEntity); + String updatePassword(String oldPassword,String newPassword,String confirmPassword,SysUserEntity sysUserEntity,String userDepartment); /** * 管理员修改用户的密码 diff --git a/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java b/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java index 88bbb0c..ab4fb78 100644 --- a/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java @@ -196,7 +196,7 @@ public class SysUserServiceImpl implements SysUserService { */ @Transactional(rollbackFor=Exception.class) @Override - public String updatePassword(String oldPassword, String newPassword, String confirmPassword, SysUserEntity sysUserEntity) { + public String updatePassword(String oldPassword, String newPassword, String confirmPassword, SysUserEntity sysUserEntity,String userDepartment) { Locale locale = LocaleContextHolder.getLocale(); String oldFrontPassword = encry256(oldPassword + sysUserEntity.getSalt()); if(!oldFrontPassword.equals(sysUserEntity.getPassword())){ @@ -206,8 +206,8 @@ public class SysUserServiceImpl implements SysUserService { 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,userDepartment); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"修改成功",locale); } /** @@ -226,8 +226,8 @@ public class SysUserServiceImpl implements SysUserService { } SysUserEntity sysUserEntity = sysUserDao.selectByUserId(userId); String newAfterPassword = encry256(newPassword + sysUserEntity.getSalt()); - sysUserDao.updatePassword(userId,newAfterPassword); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"密码修改成功",locale); + sysUserDao.updatePasswords(userId,newAfterPassword); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"修改成功",locale); } /** diff --git a/src/main/java/com/xkrs/service/impl/WorkHourRecordServiceImpl.java b/src/main/java/com/xkrs/service/impl/WorkHourRecordServiceImpl.java index b446671..cdfaee2 100644 --- a/src/main/java/com/xkrs/service/impl/WorkHourRecordServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/WorkHourRecordServiceImpl.java @@ -60,6 +60,9 @@ public class WorkHourRecordServiceImpl implements WorkHourRecordService { if(sysUserEntity == null){ return outputEncapsulationObject(PromptMessageEnum.USER_LOGIN_ERROR,"您还没有注册登录,请先注册登录",locale); } + if(workRecordQo.getWorkHour() > 24){ + return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"工时不能超过24小时,请重新填写",locale); + } WorkHourRecord workHourRecord = new WorkHourRecord(); workHourRecord.setWorkContent(workRecordQo.getWorkContent()); workHourRecord.setWorkHour(workRecordQo.getWorkHour());