From 47d26c0a6b5e6e1abd276bf54f146f3aae42b810 Mon Sep 17 00:00:00 2001 From: fengshuonan Date: Fri, 24 May 2024 10:51:12 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=908.1.7=E3=80=91=E3=80=90system=E3=80=91?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=87=8D=E7=BD=AE=E5=AF=86=E7=A0=81=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=EF=BC=8C=E8=AE=A9=E6=8E=A5=E5=8F=A3=E6=9B=B4=E5=8A=A0?= =?UTF-8?q?=E5=A4=8D=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../roses/kernel/sys/api/SysUserServiceApi.java | 8 ++++++++ .../sys/modular/user/controller/SysUserController.java | 7 ++++++- .../sys/modular/user/service/SysUserService.java | 9 --------- .../modular/user/service/impl/SysUserServiceImpl.java | 10 +++------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/sys/api/SysUserServiceApi.java b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/sys/api/SysUserServiceApi.java index 58822f6be..5cba1c5ec 100644 --- a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/sys/api/SysUserServiceApi.java +++ b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/sys/api/SysUserServiceApi.java @@ -198,4 +198,12 @@ public interface SysUserServiceApi { */ UserInfoDetailDTO getUserDetailByEmail(String email); + /** + * 重置用户密码 + * + * @author fengshuonan + * @since 2023/6/12 14:55 + */ + void resetPassword(Long userId, String newPassword); + } diff --git a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/controller/SysUserController.java b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/controller/SysUserController.java index eb7e44fc6..e2c250061 100644 --- a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/controller/SysUserController.java +++ b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/controller/SysUserController.java @@ -9,6 +9,7 @@ import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource; import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource; import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource; import cn.stylefeng.roses.kernel.sys.api.constants.PermissionCodeConstants; +import cn.stylefeng.roses.kernel.sys.api.expander.SysConfigExpander; import cn.stylefeng.roses.kernel.sys.modular.user.entity.SysUser; import cn.stylefeng.roses.kernel.sys.modular.user.pojo.request.SysUserRequest; import cn.stylefeng.roses.kernel.sys.modular.user.pojo.request.SysUserRoleRequest; @@ -152,7 +153,11 @@ public class SysUserController { requirePermissionCode = PermissionCodeConstants.RESET_PASSWORD) @BizLog(logTypeCode = PermissionCodeConstants.RESET_PASSWORD) public ResponseData resetPassword(@RequestBody @Validated(SysUserRequest.resetPassword.class) SysUserRequest sysUserRequest) { - sysUserService.resetPassword(sysUserRequest); + + // 获取系统配置的默认密码 + String password = SysConfigExpander.getDefaultPassWord(); + + sysUserService.resetPassword(sysUserRequest.getUserId(), password); return new SuccessResponseData<>(); } diff --git a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/service/SysUserService.java b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/service/SysUserService.java index cc376fc9c..611019c69 100644 --- a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/service/SysUserService.java +++ b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/service/SysUserService.java @@ -1,7 +1,6 @@ package cn.stylefeng.roses.kernel.sys.modular.user.service; import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult; -import cn.stylefeng.roses.kernel.log.api.pojo.entity.SysLogBusinessContent; import cn.stylefeng.roses.kernel.rule.pojo.dict.SimpleDict; import cn.stylefeng.roses.kernel.sys.api.SysUserServiceApi; import cn.stylefeng.roses.kernel.sys.modular.user.entity.SysUser; @@ -91,14 +90,6 @@ public interface SysUserService extends IService, SysUserServiceApi { */ void updateStatus(SysUserRequest sysUserRequest); - /** - * 重置用户密码 - * - * @author fengshuonan - * @since 2023/6/12 14:55 - */ - void resetPassword(SysUserRequest sysUserRequest); - /** * 获取当前用户的个人信息详情 * diff --git a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/service/impl/SysUserServiceImpl.java b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/service/impl/SysUserServiceImpl.java index 3a0abf6f3..b3ea17e0b 100644 --- a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/service/impl/SysUserServiceImpl.java +++ b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/service/impl/SysUserServiceImpl.java @@ -30,7 +30,6 @@ import cn.stylefeng.roses.kernel.sys.api.SecurityConfigService; import cn.stylefeng.roses.kernel.sys.api.callback.RemoveUserCallbackApi; import cn.stylefeng.roses.kernel.sys.api.constants.SysConstants; import cn.stylefeng.roses.kernel.sys.api.enums.user.UserStatusEnum; -import cn.stylefeng.roses.kernel.sys.api.expander.SysConfigExpander; import cn.stylefeng.roses.kernel.sys.api.pojo.user.*; import cn.stylefeng.roses.kernel.sys.modular.user.entity.SysUser; import cn.stylefeng.roses.kernel.sys.modular.user.enums.SysUserExceptionEnum; @@ -293,15 +292,12 @@ public class SysUserServiceImpl extends ServiceImpl impl } @Override - public void resetPassword(SysUserRequest sysUserRequest) { + public void resetPassword(Long userId, String newPassword) { - SysUser sysUser = this.querySysUser(sysUserRequest); - - // 获取系统配置的默认密码 - String password = SysConfigExpander.getDefaultPassWord(); + SysUser sysUser = this.getById(userId); // 密码加密后,存储到数据库中 - SaltedEncryptResult saltedEncryptResult = passwordStoredEncryptApi.encryptWithSalt(password); + SaltedEncryptResult saltedEncryptResult = passwordStoredEncryptApi.encryptWithSalt(newPassword); sysUser.setPassword(saltedEncryptResult.getEncryptPassword()); sysUser.setPasswordSalt(saltedEncryptResult.getPasswordSalt());