mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
禅道#1171问题修复
This commit is contained in:
+10
-3
@@ -36,6 +36,7 @@ import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.e
|
||||
import static com.cf.imes.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static com.cf.imes.module.system.dal.redis.RedisKeyConstants.OAUTH2_ACCESS_TOKEN;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.DEPT_USER_OPER_NOT_ALLOW;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.PARENT_DEPT_USER_OPER_NOT_ALLOW;
|
||||
|
||||
/**
|
||||
* 部门 Service 实现类
|
||||
@@ -105,14 +106,14 @@ public class DeptServiceImpl implements DeptService {
|
||||
@CacheEvict(cacheNames = RedisKeyConstants.DEPT_CHILDREN_ID_LIST,
|
||||
allEntries = true) // allEntries 清空所有缓存,因为操作一个部门,涉及到多个缓存
|
||||
public void deleteDept(Long id) {
|
||||
// 校验部门内用户操作
|
||||
checkCurrentWhenOperate(id);
|
||||
// 校验是否存在
|
||||
validateDeptExists(id);
|
||||
// 校验是否有子部门
|
||||
if (deptMapper.selectCountByParentId(id) > 0) {
|
||||
throw ServiceExceptionUtil.exception(ErrorCodeConstants.DEPT_EXITS_CHILDREN);
|
||||
}
|
||||
// 校验部门内用户操作
|
||||
checkCurrentWhenOperate(id);
|
||||
// 删除部门
|
||||
deptMapper.deleteById(id);
|
||||
// 删除关联的用户
|
||||
@@ -153,9 +154,15 @@ public class DeptServiceImpl implements DeptService {
|
||||
*/
|
||||
private void checkCurrentWhenOperate(Long deptId) {
|
||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||
if (ObjectUtil.isNotNull(loginUser) && ObjectUtil.equal(deptId, loginUser.getDeptId())) {
|
||||
Long currentDeptId = loginUser.getDeptId();
|
||||
if (ObjectUtil.isNotNull(loginUser) && ObjectUtil.equal(deptId, currentDeptId)) {
|
||||
throw exception(DEPT_USER_OPER_NOT_ALLOW);
|
||||
}
|
||||
// 递归查询所有下级,如果当前用户在范围内不允许操作
|
||||
List<DeptDO> childDeptList = getChildDeptList(deptId);
|
||||
childDeptList.stream().filter(d -> d.getId().equals(currentDeptId)).findAny().ifPresent(deptDO -> {
|
||||
throw exception(PARENT_DEPT_USER_OPER_NOT_ALLOW);
|
||||
});
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
||||
Reference in New Issue
Block a user