From 8c7aca2527336182fa0a8a476c2274b68acfa54f Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: Sat, 16 May 2020 17:15:13 +0800
Subject: [PATCH] 缺少 @Override
---
ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDeptController.java | 23 +++++++++++++++--------
1 files changed, 15 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..21b0576 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
@@ -3,6 +3,7 @@
import java.util.List;
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 +11,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 +42,7 @@
public AjaxResult list(SysDept dept)
{
List<SysDept> depts = deptService.selectDeptList(dept);
- return AjaxResult.success(deptService.buildDeptTree(depts));
+ return AjaxResult.success(depts);
}
/**
@@ -57,7 +58,6 @@
/**
* 获取部门下拉树列表
*/
- @PreAuthorize("@ss.hasPermi('system:dept:query')")
@GetMapping("/treeselect")
public AjaxResult treeselect(SysDept dept)
{
@@ -68,12 +68,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 +84,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 +100,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 +110,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