|
|
@@ -1,6 +1,7 @@
|
|
|
package com.zhongzheng.controller.system;
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import com.zhongzheng.common.annotation.Log;
|
|
|
import com.zhongzheng.common.constant.UserConstants;
|
|
|
import com.zhongzheng.common.core.controller.BaseController;
|
|
|
@@ -9,20 +10,25 @@ import com.zhongzheng.common.core.domain.entity.SysDept;
|
|
|
import com.zhongzheng.common.enums.BusinessType;
|
|
|
import com.zhongzheng.common.utils.SecurityUtils;
|
|
|
import com.zhongzheng.modules.system.service.ISysDeptService;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
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.*;
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.Iterator;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* 部门信息
|
|
|
*
|
|
|
* @author zhongzheng
|
|
|
*/
|
|
|
+@Api(tags ="部门信息管理")
|
|
|
@RestController
|
|
|
@RequestMapping("/system/dept")
|
|
|
public class SysDeptController extends BaseController
|
|
|
@@ -33,6 +39,7 @@ public class SysDeptController extends BaseController
|
|
|
/**
|
|
|
* 获取部门列表
|
|
|
*/
|
|
|
+ @ApiOperation("部门列表")
|
|
|
@PreAuthorize("@ss.hasPermi('system:dept:list')")
|
|
|
@GetMapping("/list")
|
|
|
public AjaxResult list(SysDept dept)
|
|
|
@@ -44,6 +51,7 @@ public class SysDeptController extends BaseController
|
|
|
/**
|
|
|
* 查询部门列表(排除节点)
|
|
|
*/
|
|
|
+ @ApiOperation("查询部门列表(节点)")
|
|
|
@PreAuthorize("@ss.hasPermi('system:dept:list')")
|
|
|
@GetMapping("/list/exclude/{deptId}")
|
|
|
public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId)
|
|
|
@@ -65,6 +73,7 @@ public class SysDeptController extends BaseController
|
|
|
/**
|
|
|
* 根据部门编号获取详细信息
|
|
|
*/
|
|
|
+ @ApiOperation("根据部门编号获取详细信息")
|
|
|
@PreAuthorize("@ss.hasPermi('system:dept:query')")
|
|
|
@GetMapping(value = "/{deptId}")
|
|
|
public AjaxResult getInfo(@PathVariable Long deptId)
|
|
|
@@ -75,6 +84,7 @@ public class SysDeptController extends BaseController
|
|
|
/**
|
|
|
* 获取部门下拉树列表
|
|
|
*/
|
|
|
+ @ApiOperation("获取部门下拉树列表")
|
|
|
@GetMapping("/treeselect")
|
|
|
public AjaxResult treeselect(SysDept dept)
|
|
|
{
|
|
|
@@ -85,19 +95,22 @@ public class SysDeptController extends BaseController
|
|
|
/**
|
|
|
* 加载对应角色部门列表树
|
|
|
*/
|
|
|
+ @ApiOperation("加载对应角色部门列表树")
|
|
|
@GetMapping(value = "/roleDeptTreeselect/{roleId}")
|
|
|
public AjaxResult roleDeptTreeselect(@PathVariable("roleId") Long 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;
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ map.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
|
|
|
+ map.put("depts", deptService.buildDeptTreeSelect(depts));
|
|
|
+ return AjaxResult.success(map);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 新增部门
|
|
|
*/
|
|
|
+ @ApiOperation("新增部门")
|
|
|
+ @ApiOperationSupport(includeParameters = {"deptName","parentId","orderNum","status"})
|
|
|
@PreAuthorize("@ss.hasPermi('system:dept:add')")
|
|
|
@Log(title = "部门管理", businessType = BusinessType.INSERT)
|
|
|
@PostMapping
|
|
|
@@ -114,9 +127,10 @@ public class SysDeptController extends BaseController
|
|
|
/**
|
|
|
* 修改部门
|
|
|
*/
|
|
|
+ @ApiOperation("修改部门")
|
|
|
@PreAuthorize("@ss.hasPermi('system:dept:edit')")
|
|
|
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
|
|
|
- @PutMapping
|
|
|
+ @PostMapping("/edit")
|
|
|
public AjaxResult edit(@Validated @RequestBody SysDept dept)
|
|
|
{
|
|
|
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
|
|
|
@@ -139,9 +153,10 @@ public class SysDeptController extends BaseController
|
|
|
/**
|
|
|
* 删除部门
|
|
|
*/
|
|
|
+ @ApiOperation("删除部门")
|
|
|
@PreAuthorize("@ss.hasPermi('system:dept:remove')")
|
|
|
@Log(title = "部门管理", businessType = BusinessType.DELETE)
|
|
|
- @DeleteMapping("/{deptId}")
|
|
|
+ @PostMapping("/delete/{deptId}")
|
|
|
public AjaxResult remove(@PathVariable Long deptId)
|
|
|
{
|
|
|
if (deptService.hasChildByDeptId(deptId))
|