From a195df175f3031d682eccd1fc764ad2033d92b5f Mon Sep 17 00:00:00 2001 From: RuoYi <yzz_ivy@163.com> Date: 星期四, 18 六月 2020 15:07:56 +0800 Subject: [PATCH] 修正定时任务日志权限字符 --- ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDeptController.java | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 38 insertions(+), 8 deletions(-) diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDeptController.java b/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDeptController.java index 00700b1..e549a43 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDeptController.java +++ b/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDeptController.java @@ -1,8 +1,11 @@ package com.ruoyi.project.system.controller; +import java.util.Iterator; import java.util.List; +import org.apache.commons.lang3.ArrayUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -10,10 +13,10 @@ import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.StringUtils; import com.ruoyi.framework.aspectj.lang.annotation.Log; import com.ruoyi.framework.aspectj.lang.enums.BusinessType; import com.ruoyi.framework.web.controller.BaseController; @@ -41,7 +44,28 @@ public AjaxResult list(SysDept dept) { List<SysDept> depts = deptService.selectDeptList(dept); - return AjaxResult.success(deptService.buildDeptTree(depts)); + return AjaxResult.success(depts); + } + + /** + * 查询部门列表(排除节点) + */ + @PreAuthorize("@ss.hasPermi('system:dept:list')") + @GetMapping("/list/exclude/{deptId}") + public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) + { + List<SysDept> depts = deptService.selectDeptList(new SysDept()); + Iterator<SysDept> it = depts.iterator(); + while (it.hasNext()) + { + SysDept d = (SysDept) it.next(); + if (d.getDeptId().intValue() == deptId + || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")) + { + it.remove(); + } + } + return AjaxResult.success(depts); } /** @@ -57,7 +81,6 @@ /** * 获取部门下拉树列表 */ - @PreAuthorize("@ss.hasPermi('system:dept:query')") @GetMapping("/treeselect") public AjaxResult treeselect(SysDept dept) { @@ -68,12 +91,14 @@ /** * 加载对应角色部门列表树 */ - @PreAuthorize("@ss.hasPermi('system:dept:query')") @GetMapping(value = "/roleDeptTreeselect/{roleId}") - @ResponseBody public AjaxResult roleDeptTreeselect(@PathVariable("roleId") Long roleId) { - return AjaxResult.success(deptService.selectDeptListByRoleId(roleId)); + List<SysDept> depts = deptService.selectDeptList(new SysDept()); + AjaxResult ajax = AjaxResult.success(); + ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId)); + ajax.put("depts", deptService.buildDeptTreeSelect(depts)); + return ajax; } /** @@ -82,7 +107,7 @@ @PreAuthorize("@ss.hasPermi('system:dept:add')") @Log(title = "部门管理", businessType = BusinessType.INSERT) @PostMapping - public AjaxResult add(@RequestBody SysDept dept) + public AjaxResult add(@Validated @RequestBody SysDept dept) { if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) { @@ -98,7 +123,7 @@ @PreAuthorize("@ss.hasPermi('system:dept:edit')") @Log(title = "部门管理", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult edit(@RequestBody SysDept dept) + public AjaxResult edit(@Validated @RequestBody SysDept dept) { if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) { @@ -108,6 +133,11 @@ { return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己"); } + else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) + && deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0) + { + return AjaxResult.error("该部门包含未停用的子部门!"); + } dept.setUpdateBy(SecurityUtils.getUsername()); return toAjax(deptService.updateDept(dept)); } -- Gitblit v1.9.2