fix 替换查询所有子部门数中魔法值为已定义的常量

This commit is contained in:
konbai 2022-01-22 14:45:00 +08:00
parent 91d88b6d7d
commit 1564001257
3 changed files with 6 additions and 6 deletions

View File

@ -121,7 +121,7 @@ public class SysDeptController extends BaseController {
} else if (dept.getParentId().equals(dept.getDeptId())) { } else if (dept.getParentId().equals(dept.getDeptId())) {
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己"); return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
} else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) } else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus())
&& deptService.checkNormalChildrenDeptById(dept.getDeptId())) { && deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0) {
return AjaxResult.error("该部门包含未停用的子部门!"); return AjaxResult.error("该部门包含未停用的子部门!");
} }
return toAjax(deptService.updateDept(dept)); return toAjax(deptService.updateDept(dept));

View File

@ -44,12 +44,12 @@ public interface ISysDeptService {
SysDept selectDeptById(Long deptId); SysDept selectDeptById(Long deptId);
/** /**
* 根据ID查询所有子部门是否存在正常状态 * 根据ID查询所有子部门正常状态
* *
* @param deptId 部门ID * @param deptId 部门ID
* @return 子部门数 * @return 子部门数
*/ */
boolean checkNormalChildrenDeptById(Long deptId); long selectNormalChildrenDeptById(Long deptId);
/** /**
* 是否存在部门子节点 * 是否存在部门子节点

View File

@ -92,14 +92,14 @@ public class SysDeptServiceImpl implements ISysDeptService {
} }
/** /**
* 根据ID查询所有子部门是否存在正常状态 * 根据ID查询所有子部门正常状态
* *
* @param deptId 部门ID * @param deptId 部门ID
* @return 子部门数 * @return 子部门数
*/ */
@Override @Override
public boolean checkNormalChildrenDeptById(Long deptId) { public long selectNormalChildrenDeptById(Long deptId) {
return baseMapper.exists(new LambdaQueryWrapper<SysDept>() return baseMapper.selectCount(new LambdaQueryWrapper<SysDept>()
.eq(SysDept::getStatus, UserConstants.DEPT_NORMAL) .eq(SysDept::getStatus, UserConstants.DEPT_NORMAL)
.apply("find_in_set({0}, ancestors)", deptId)); .apply("find_in_set({0}, ancestors)", deptId));
} }