mirror of https://gitee.com/stylefeng/roses
【7.6.0】【sys】【auth】整理用于校验用户密码的查询用户信息接口
parent
44b9871c47
commit
e616839a72
|
@ -26,6 +26,7 @@ package cn.stylefeng.roses.kernel.sys.api;
|
|||
|
||||
import cn.stylefeng.roses.kernel.sys.api.pojo.user.SimpleUserDTO;
|
||||
import cn.stylefeng.roses.kernel.sys.api.pojo.user.UserOrgDTO;
|
||||
import cn.stylefeng.roses.kernel.sys.api.pojo.user.UserValidateDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -89,4 +90,12 @@ public interface SysUserServiceApi {
|
|||
*/
|
||||
String getUserRealName(Long userId);
|
||||
|
||||
/**
|
||||
* 获取用于用户校验的
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/6/17 21:56
|
||||
*/
|
||||
UserValidateDTO getUserValidateDTO(Long account);
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* 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.pojo.user;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 用在用户登录校验结果的包装
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/6/17 21:55
|
||||
*/
|
||||
@Data
|
||||
public class UserValidateDTO {
|
||||
|
||||
/**
|
||||
* 加密后的密码,存在sys_user表的password字段
|
||||
*/
|
||||
@ChineseDescription("加密后的密码")
|
||||
private String userPasswordHexed;
|
||||
|
||||
/**
|
||||
* 用户状态,状态在UserStatusEnum维护
|
||||
*/
|
||||
@ChineseDescription("用户状态")
|
||||
private Integer userStatus;
|
||||
|
||||
public UserValidateDTO() {
|
||||
}
|
||||
|
||||
public UserValidateDTO(String userPasswordHexed, Integer userStatus) {
|
||||
this.userPasswordHexed = userPasswordHexed;
|
||||
this.userStatus = userStatus;
|
||||
}
|
||||
}
|
|
@ -4,13 +4,16 @@ import cn.hutool.core.util.ObjectUtil;
|
|||
import cn.stylefeng.roses.kernel.db.api.DbOperatorApi;
|
||||
import cn.stylefeng.roses.kernel.file.api.FileInfoApi;
|
||||
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||
import cn.stylefeng.roses.kernel.sys.api.SysUserServiceApi;
|
||||
import cn.stylefeng.roses.kernel.sys.api.exception.SysException;
|
||||
import cn.stylefeng.roses.kernel.sys.api.pojo.user.SimpleUserDTO;
|
||||
import cn.stylefeng.roses.kernel.sys.api.pojo.user.UserOrgDTO;
|
||||
import cn.stylefeng.roses.kernel.sys.api.pojo.user.UserValidateDTO;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.entity.SysUser;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.entity.SysUserOrg;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.entity.SysUserRole;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.enums.SysUserExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.factory.UserOrgFactory;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.service.SysUserOrgService;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.service.SysUserRoleService;
|
||||
|
@ -174,4 +177,19 @@ public class UserIntegrationService implements SysUserServiceApi {
|
|||
return sysUser.getRealName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserValidateDTO getUserValidateDTO(Long account) {
|
||||
|
||||
LambdaQueryWrapper<SysUser> sysUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
sysUserLambdaQueryWrapper.eq(SysUser::getAccount, account);
|
||||
sysUserLambdaQueryWrapper.select(SysUser::getPassword, SysUser::getStatusFlag);
|
||||
SysUser sysUserServiceOne = this.sysUserService.getOne(sysUserLambdaQueryWrapper, false);
|
||||
|
||||
if (sysUserServiceOne == null) {
|
||||
throw new ServiceException(SysUserExceptionEnum.ACCOUNT_NOT_EXIST);
|
||||
}
|
||||
|
||||
return new UserValidateDTO(sysUserServiceOne.getPassword(), sysUserServiceOne.getStatusFlag());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,7 +21,14 @@ public enum SysUserExceptionEnum implements AbstractExceptionEnum {
|
|||
/**
|
||||
* 不能删除超级管理员
|
||||
*/
|
||||
USER_CAN_NOT_DELETE_ADMIN(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10002", "不能删除超级管理员");
|
||||
USER_CAN_NOT_DELETE_ADMIN(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10002", "不能删除超级管理员"),
|
||||
|
||||
/**
|
||||
* 用户账号不存在
|
||||
* <p>
|
||||
* 但是提示:用户账号或密码错误,请重新输入
|
||||
*/
|
||||
ACCOUNT_NOT_EXIST(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10003", "用户账号或密码错误,请重新输入");
|
||||
|
||||
/**
|
||||
* 错误编码
|
||||
|
|
Loading…
Reference in New Issue