【8.1.7】【system】更新重置密码接口,让接口更加复用

dev-8.1.9 v8.1.7
fengshuonan 2024-05-24 10:51:12 +08:00
parent 7e2e6894fd
commit 47d26c0a6b
4 changed files with 17 additions and 17 deletions

View File

@ -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);
}

View File

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

View File

@ -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<SysUser>, SysUserServiceApi {
*/
void updateStatus(SysUserRequest sysUserRequest);
/**
*
*
* @author fengshuonan
* @since 2023/6/12 14:55
*/
void resetPassword(SysUserRequest sysUserRequest);
/**
*
*

View File

@ -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<SysUserMapper, SysUser> 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());