新增-es查询缺少字段判断,部门不存在时也可以登录

This commit is contained in:
liuzhaotian
2025-03-17 11:21:34 +08:00
parent 77ff867e86
commit 51532b2c67
6 changed files with 54 additions and 7 deletions
@@ -111,7 +111,7 @@ public class AdminAuthServiceImpl implements AdminAuthService {
// 校验机构有效性
organService.validOrgan(user.getOrganId());
// 校验部门有效性
deptService.validDept(user.getDeptId());
deptService.validUserLoginDept(user.getDeptId());
// 校验密码
if (!userService.isPasswordMatch(password, user.getPassword())) {
createLoginLog(user.getId(), username, logTypeEnum, LoginResultEnum.BAD_CREDENTIALS);
@@ -106,6 +106,13 @@ public interface DeptService {
*/
void validDept(Long deptId);
/**
* 用户登陆时部门校验
*
* @param deptId
*/
void validUserLoginDept(Long deptId);
/**
* 移除没有归属(上级)的部门
*
@@ -309,6 +309,25 @@ public class DeptServiceImpl implements DeptService {
validParentDept(deptDO);
}
// 用户登陆时部门校验,部门不存在时也可以进行登录
@Override
public void validUserLoginDept(Long deptId){
DeptDO deptDO = deptMapper.selectById(deptId);
if (deptDO == null) {
return;
}
if (!CommonStatusEnum.ENABLE.getStatus().equals(deptDO.getStatus())) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.DEPT_DISABLE, deptDO.getName());
}
// 递归校验上级部门
validParentDept(deptDO);
}
/**
* 递归校验上级部门
*