【7.6.0】【sys】【user】更新重置密码

pull/55/MERGE
fengshuonan 2023-06-12 15:00:43 +08:00
parent bd83a4f3d8
commit af66fc1aaa
6 changed files with 94 additions and 2 deletions

View File

@ -42,4 +42,9 @@ public interface SysConstants {
*/
String SYS_EXCEPTION_STEP_CODE = "99";
/**
*
*/
String DEFAULT_LOGIN_PASSWORD = "Aa123456!";
}

View File

@ -0,0 +1,49 @@
/*
* Copyright [2020-2030] [https://www.stylefeng.cn]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* GunsAPACHE LICENSE 2.0使
*
* 1.LICENSE
* 2.Guns
* 3.
* 4. https://gitee.com/stylefeng/guns
* 5. https://gitee.com/stylefeng/guns
* 6.
*/
package cn.stylefeng.roses.kernel.sys.api.expander;
import cn.stylefeng.roses.kernel.config.api.context.ConfigContext;
import cn.stylefeng.roses.kernel.sys.api.constants.SysConstants;
/**
*
*
* @author fengshuonan
* @since 2020/12/27 17:13
*/
public class SysConfigExpander {
/**
*
*
* @author luojie
* @since 2020/11/6 10:05
*/
public static String getDefaultPassWord() {
return ConfigContext.me().getSysConfigValueWithDefault("SYS_DEFAULT_PASSWORD", String.class, SysConstants.DEFAULT_LOGIN_PASSWORD);
}
}

View File

@ -128,4 +128,16 @@ public class SysUserController {
return new SuccessResponseData<>();
}
/**
*
*
* @author fengshuonan
* @since 2023/6/12 14:49
*/
@PostResource(name = "重置用户密码", path = "/sysUser/resetPassword")
public ResponseData<?> resetPassword(@RequestBody @Validated(SysUserRequest.resetPassword.class) SysUserRequest sysUserRequest) {
sysUserService.resetPassword(sysUserRequest);
return new SuccessResponseData<>();
}
}

View File

@ -27,7 +27,7 @@ public class SysUserRequest extends BaseRequest {
/**
*
*/
@NotNull(message = "主键不能为空", groups = {edit.class, delete.class, updateStatus.class})
@NotNull(message = "主键不能为空", groups = {edit.class, delete.class, detail.class, updateStatus.class, resetPassword.class})
@ChineseDescription("主键")
private Long userId;
@ -146,4 +146,10 @@ public class SysUserRequest extends BaseRequest {
@NotEmpty(message = "用户id集合不能为空", groups = batchDelete.class)
private Set<Long> userIdList;
/**
*
*/
public @interface resetPassword {
}
}

View File

@ -87,4 +87,12 @@ public interface SysUserService extends IService<SysUser> {
*/
void updateStatus(SysUserRequest sysUserRequest);
/**
*
*
* @author fengshuonan
* @since 2023/6/12 14:55
*/
void resetPassword(SysUserRequest sysUserRequest);
}

View File

@ -15,6 +15,7 @@ import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
import cn.stylefeng.roses.kernel.sys.api.SysUserServiceApi;
import cn.stylefeng.roses.kernel.sys.api.callback.RemoveUserCallbackApi;
import cn.stylefeng.roses.kernel.sys.api.enums.UserStatusEnum;
import cn.stylefeng.roses.kernel.sys.api.expander.SysConfigExpander;
import cn.stylefeng.roses.kernel.sys.api.pojo.UserOrgDTO;
import cn.stylefeng.roses.kernel.sys.modular.user.entity.SysUser;
import cn.stylefeng.roses.kernel.sys.modular.user.enums.SysUserExceptionEnum;
@ -168,6 +169,17 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
}
@Override
public void resetPassword(SysUserRequest sysUserRequest) {
SysUser sysUser = this.querySysUser(sysUserRequest);
// 获取系统配置的默认密码
String password = SysConfigExpander.getDefaultPassWord();
sysUser.setPassword(passwordStoredEncryptApi.encrypt(password));
this.updateById(sysUser);
}
@Override
public List<SysUser> findList(SysUserRequest sysUserRequest) {
LambdaQueryWrapper<SysUser> wrapper = this.createWrapper(sysUserRequest);