From 0b852faf00776601e7ecd6c4d57f4f75ce70caff Mon Sep 17 00:00:00 2001 From: 疯狂的狮子li <15040126243@163.com> Date: 星期六, 29 一月 2022 09:23:11 +0800 Subject: [PATCH] Merge remote-tracking branch 'ruoyi-vue/master' into dev --- ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java index 08ebf96..0575225 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java @@ -15,7 +15,6 @@ import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.RequiredArgsConstructor; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -30,7 +29,7 @@ */ @Validated @Api(value = "閮ㄩ棬鎺у埗鍣�", tags = {"閮ㄩ棬绠$悊"}) -@RequiredArgsConstructor(onConstructor_ = @Autowired) +@RequiredArgsConstructor @RestController @RequestMapping("/system/dept") public class SysDeptController extends BaseController { @@ -57,7 +56,7 @@ public AjaxResult<List<SysDept>> excludeChild(@ApiParam("閮ㄩ棬ID") @PathVariable(value = "deptId", required = false) Long deptId) { List<SysDept> depts = deptService.selectDeptList(new SysDept()); depts.removeIf(d -> d.getDeptId().equals(deptId) - || ArrayUtil.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")); + || ArrayUtil.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")); return AjaxResult.success(depts); } @@ -117,12 +116,14 @@ @Log(title = "閮ㄩ棬绠$悊", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult<Void> edit(@Validated @RequestBody SysDept dept) { + Long deptId = dept.getDeptId(); + deptService.checkDeptDataScope(deptId); if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) { return AjaxResult.error("淇敼閮ㄩ棬'" + dept.getDeptName() + "'澶辫触锛岄儴闂ㄥ悕绉板凡瀛樺湪"); - } else if (dept.getParentId().equals(dept.getDeptId())) { + } else if (dept.getParentId().equals(deptId)) { return AjaxResult.error("淇敼閮ㄩ棬'" + dept.getDeptName() + "'澶辫触锛屼笂绾ч儴闂ㄤ笉鑳芥槸鑷繁"); } else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) - && deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0) { + && deptService.selectNormalChildrenDeptById(deptId) > 0) { return AjaxResult.error("璇ラ儴闂ㄥ寘鍚湭鍋滅敤鐨勫瓙閮ㄩ棬锛�"); } return toAjax(deptService.updateDept(dept)); @@ -142,6 +143,7 @@ if (deptService.checkDeptExistUser(deptId)) { return AjaxResult.error("閮ㄩ棬瀛樺湪鐢ㄦ埛,涓嶅厑璁稿垹闄�"); } + deptService.checkDeptDataScope(deptId); return toAjax(deptService.deleteDeptById(deptId)); } } -- Gitblit v1.9.3