mirror of https://gitee.com/stylefeng/roses
【7.6.0】【sys】【user】更新重置密码
parent
bd83a4f3d8
commit
af66fc1aaa
|
@ -42,4 +42,9 @@ public interface SysConstants {
|
||||||
*/
|
*/
|
||||||
String SYS_EXCEPTION_STEP_CODE = "99";
|
String SYS_EXCEPTION_STEP_CODE = "99";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认登录密码
|
||||||
|
*/
|
||||||
|
String DEFAULT_LOGIN_PASSWORD = "Aa123456!";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.
|
||||||
|
*
|
||||||
|
* Guns采用APACHE 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -128,4 +128,16 @@ public class SysUserController {
|
||||||
return new SuccessResponseData<>();
|
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<>();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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("主键")
|
@ChineseDescription("主键")
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
|
@ -146,4 +146,10 @@ public class SysUserRequest extends BaseRequest {
|
||||||
@NotEmpty(message = "用户id集合不能为空", groups = batchDelete.class)
|
@NotEmpty(message = "用户id集合不能为空", groups = batchDelete.class)
|
||||||
private Set<Long> userIdList;
|
private Set<Long> userIdList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数校验分组:重置用户密码
|
||||||
|
*/
|
||||||
|
public @interface resetPassword {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,5 +86,13 @@ public interface SysUserService extends IService<SysUser> {
|
||||||
* @since 2023/6/12 10:59
|
* @since 2023/6/12 10:59
|
||||||
*/
|
*/
|
||||||
void updateStatus(SysUserRequest sysUserRequest);
|
void updateStatus(SysUserRequest sysUserRequest);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重置用户密码
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2023/6/12 14:55
|
||||||
|
*/
|
||||||
|
void resetPassword(SysUserRequest sysUserRequest);
|
||||||
|
|
||||||
}
|
}
|
|
@ -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.SysUserServiceApi;
|
||||||
import cn.stylefeng.roses.kernel.sys.api.callback.RemoveUserCallbackApi;
|
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.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.api.pojo.UserOrgDTO;
|
||||||
import cn.stylefeng.roses.kernel.sys.modular.user.entity.SysUser;
|
import cn.stylefeng.roses.kernel.sys.modular.user.entity.SysUser;
|
||||||
import cn.stylefeng.roses.kernel.sys.modular.user.enums.SysUserExceptionEnum;
|
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
|
@Override
|
||||||
public List<SysUser> findList(SysUserRequest sysUserRequest) {
|
public List<SysUser> findList(SysUserRequest sysUserRequest) {
|
||||||
LambdaQueryWrapper<SysUser> wrapper = this.createWrapper(sysUserRequest);
|
LambdaQueryWrapper<SysUser> wrapper = this.createWrapper(sysUserRequest);
|
||||||
|
|
Loading…
Reference in New Issue