mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-19 17:58:17 +08:00
fix 替换查询所有子部门数中魔法值为已定义的常量
This commit is contained in:
parent
91d88b6d7d
commit
1564001257
@ -121,7 +121,7 @@ public class SysDeptController extends BaseController {
|
||||
} else if (dept.getParentId().equals(dept.getDeptId())) {
|
||||
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
|
||||
} else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus())
|
||||
&& deptService.checkNormalChildrenDeptById(dept.getDeptId())) {
|
||||
&& deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0) {
|
||||
return AjaxResult.error("该部门包含未停用的子部门!");
|
||||
}
|
||||
return toAjax(deptService.updateDept(dept));
|
||||
|
||||
@ -44,12 +44,12 @@ public interface ISysDeptService {
|
||||
SysDept selectDeptById(Long deptId);
|
||||
|
||||
/**
|
||||
* 根据ID查询所有子部门是否存在(正常状态)
|
||||
* 根据ID查询所有子部门数(正常状态)
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
* @return 子部门数
|
||||
*/
|
||||
boolean checkNormalChildrenDeptById(Long deptId);
|
||||
long selectNormalChildrenDeptById(Long deptId);
|
||||
|
||||
/**
|
||||
* 是否存在部门子节点
|
||||
|
||||
@ -92,14 +92,14 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询所有子部门是否存在(正常状态)
|
||||
* 根据ID查询所有子部门数(正常状态)
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
* @return 子部门数
|
||||
*/
|
||||
@Override
|
||||
public boolean checkNormalChildrenDeptById(Long deptId) {
|
||||
return baseMapper.exists(new LambdaQueryWrapper<SysDept>()
|
||||
public long selectNormalChildrenDeptById(Long deptId) {
|
||||
return baseMapper.selectCount(new LambdaQueryWrapper<SysDept>()
|
||||
.eq(SysDept::getStatus, UserConstants.DEPT_NORMAL)
|
||||
.apply("find_in_set({0}, ancestors)", deptId));
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user