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());