正在显示
6 个修改的文件
包含
42 行增加
和
2 行删除
| @@ -19,14 +19,17 @@ public class UserConstants | @@ -19,14 +19,17 @@ public class UserConstants | ||
| 19 | public static final String EXCEPTION = "1"; | 19 | public static final String EXCEPTION = "1"; |
| 20 | 20 | ||
| 21 | /** 用户封禁状态 */ | 21 | /** 用户封禁状态 */ |
| 22 | - public static final String USER_BLOCKED = "1"; | 22 | + public static final String USER_DISABLE = "1"; |
| 23 | 23 | ||
| 24 | /** 角色封禁状态 */ | 24 | /** 角色封禁状态 */ |
| 25 | - public static final String ROLE_BLOCKED = "1"; | 25 | + public static final String ROLE_DISABLE = "1"; |
| 26 | 26 | ||
| 27 | /** 部门正常状态 */ | 27 | /** 部门正常状态 */ |
| 28 | public static final String DEPT_NORMAL = "0"; | 28 | public static final String DEPT_NORMAL = "0"; |
| 29 | 29 | ||
| 30 | + /** 部门停用状态 */ | ||
| 31 | + public static final String DEPT_DISABLE = "1"; | ||
| 32 | + | ||
| 30 | /** 字典正常状态 */ | 33 | /** 字典正常状态 */ |
| 31 | public static final String DICT_NORMAL = "0"; | 34 | public static final String DICT_NORMAL = "0"; |
| 32 | 35 |
| @@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMapping; | @@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMapping; | ||
| 14 | import org.springframework.web.bind.annotation.RestController; | 14 | import org.springframework.web.bind.annotation.RestController; |
| 15 | import com.ruoyi.common.constant.UserConstants; | 15 | import com.ruoyi.common.constant.UserConstants; |
| 16 | import com.ruoyi.common.utils.SecurityUtils; | 16 | import com.ruoyi.common.utils.SecurityUtils; |
| 17 | +import com.ruoyi.common.utils.StringUtils; | ||
| 17 | import com.ruoyi.framework.aspectj.lang.annotation.Log; | 18 | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| 18 | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; | 19 | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| 19 | import com.ruoyi.framework.web.controller.BaseController; | 20 | import com.ruoyi.framework.web.controller.BaseController; |
| @@ -109,6 +110,11 @@ public class SysDeptController extends BaseController | @@ -109,6 +110,11 @@ public class SysDeptController extends BaseController | ||
| 109 | { | 110 | { |
| 110 | return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己"); | 111 | return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己"); |
| 111 | } | 112 | } |
| 113 | + else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) | ||
| 114 | + && deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0) | ||
| 115 | + { | ||
| 116 | + return AjaxResult.error("该部门包含未停用的子部门!"); | ||
| 117 | + } | ||
| 112 | dept.setUpdateBy(SecurityUtils.getUsername()); | 118 | dept.setUpdateBy(SecurityUtils.getUsername()); |
| 113 | return toAjax(deptService.updateDept(dept)); | 119 | return toAjax(deptService.updateDept(dept)); |
| 114 | } | 120 | } |
| @@ -44,6 +44,14 @@ public interface SysDeptMapper | @@ -44,6 +44,14 @@ public interface SysDeptMapper | ||
| 44 | public List<SysDept> selectChildrenDeptById(Long deptId); | 44 | public List<SysDept> selectChildrenDeptById(Long deptId); |
| 45 | 45 | ||
| 46 | /** | 46 | /** |
| 47 | + * 根据ID查询所有子部门(正常状态) | ||
| 48 | + * | ||
| 49 | + * @param deptId 部门ID | ||
| 50 | + * @return 子部门数 | ||
| 51 | + */ | ||
| 52 | + public int selectNormalChildrenDeptById(Long deptId); | ||
| 53 | + | ||
| 54 | + /** | ||
| 47 | * 是否存在子节点 | 55 | * 是否存在子节点 |
| 48 | * | 56 | * |
| 49 | * @param deptId 部门ID | 57 | * @param deptId 部门ID |
| @@ -52,6 +52,14 @@ public interface ISysDeptService | @@ -52,6 +52,14 @@ public interface ISysDeptService | ||
| 52 | public SysDept selectDeptById(Long deptId); | 52 | public SysDept selectDeptById(Long deptId); |
| 53 | 53 | ||
| 54 | /** | 54 | /** |
| 55 | + * 根据ID查询所有子部门(正常状态) | ||
| 56 | + * | ||
| 57 | + * @param deptId 部门ID | ||
| 58 | + * @return 子部门数 | ||
| 59 | + */ | ||
| 60 | + public int selectNormalChildrenDeptById(Long deptId); | ||
| 61 | + | ||
| 62 | + /** | ||
| 55 | * 是否存在部门子节点 | 63 | * 是否存在部门子节点 |
| 56 | * | 64 | * |
| 57 | * @param deptId 部门ID | 65 | * @param deptId 部门ID |
| @@ -109,6 +109,17 @@ public class SysDeptServiceImpl implements ISysDeptService | @@ -109,6 +109,17 @@ public class SysDeptServiceImpl implements ISysDeptService | ||
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | /** | 111 | /** |
| 112 | + * 根据ID查询所有子部门(正常状态) | ||
| 113 | + * | ||
| 114 | + * @param deptId 部门ID | ||
| 115 | + * @return 子部门数 | ||
| 116 | + */ | ||
| 117 | + public int selectNormalChildrenDeptById(Long deptId) | ||
| 118 | + { | ||
| 119 | + return deptMapper.selectNormalChildrenDeptById(deptId); | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + /** | ||
| 112 | * 是否存在子节点 | 123 | * 是否存在子节点 |
| 113 | * | 124 | * |
| 114 | * @param deptId 部门ID | 125 | * @param deptId 部门ID |
| @@ -71,6 +71,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -71,6 +71,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 71 | select * from sys_dept where find_in_set(#{deptId}, ancestors) | 71 | select * from sys_dept where find_in_set(#{deptId}, ancestors) |
| 72 | </select> | 72 | </select> |
| 73 | 73 | ||
| 74 | + <select id="selectNormalChildrenDeptById" parameterType="Long" resultType="java.lang.Integer"> | ||
| 75 | + select count(*) from sys_dept where status = 0 and del_flag = '0' and find_in_set(#{deptId}, ancestors) | ||
| 76 | + </select> | ||
| 77 | + | ||
| 74 | <select id="checkDeptNameUnique" resultMap="SysDeptResult"> | 78 | <select id="checkDeptNameUnique" resultMap="SysDeptResult"> |
| 75 | <include refid="selectDeptVo"/> | 79 | <include refid="selectDeptVo"/> |
| 76 | where dept_name=#{deptName} and parent_id = #{parentId} | 80 | where dept_name=#{deptName} and parent_id = #{parentId} |
-
请 注册 或 登录 后发表评论