添加校验部门包含未停用的子部门

master
RuoYi 4 years ago committed by Limy
parent 7f08603c4f
commit 1d9b03935b

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

@ -19,14 +19,17 @@ public class UserConstants
public static final String EXCEPTION = "1";
/** 用户封禁状态 */
public static final String USER_BLOCKED = "1";
public static final String USER_DISABLE = "1";
/** 角色封禁状态 */
public static final String ROLE_BLOCKED = "1";
public static final String ROLE_DISABLE = "1";
/** 部门正常状态 */
public static final String DEPT_NORMAL = "0";
/** 部门停用状态 */
public static final String DEPT_DISABLE = "1";
/** 字典正常状态 */
public static final String DICT_NORMAL = "0";

@ -101,8 +101,17 @@ public interface SysDeptMapper
/**
* ID
*
* @param deptId ID
* @return
*/
public List<SysDept> selectChildrenDeptById(Long deptId);
/**
* ID
*
* @param deptId ID
* @return
*/
public int selectNormalChildrenDeptById(Long deptId);
}

@ -84,6 +84,14 @@ public interface ISysDeptService
*/
public SysDept selectDeptById(Long deptId);
/**
* ID
*
* @param deptId ID
* @return
*/
public int selectNormalChildrenDeptById(Long deptId);
/**
*
*

@ -251,6 +251,17 @@ public class SysDeptServiceImpl implements ISysDeptService
return deptMapper.selectDeptById(deptId);
}
/**
* ID
*
* @param deptId ID
* @return
*/
public int selectNormalChildrenDeptById(Long deptId)
{
return deptMapper.selectNormalChildrenDeptById(deptId);
}
/**
*
*

@ -79,6 +79,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select * from sys_dept where find_in_set(#{deptId}, ancestors)
</select>
<select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int">
select count(*) from sys_dept where status = 0 and del_flag = '0' and find_in_set(#{deptId}, ancestors)
</select>
<insert id="insertDept" parameterType="SysDept">
insert into sys_dept(
<if test="deptId != null and deptId != 0">dept_id,</if>

Loading…
Cancel
Save