package org.jeecg.modules.dnc.controller; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.jeecg.common.aspect.annotation.AutoLog; import org.jeecg.modules.dnc.request.DepartmentRequest; import org.jeecg.modules.dnc.response.*; import org.jeecg.modules.dnc.service.IDepartmentService; import org.jeecg.modules.dnc.ucenter.Department; import org.jeecg.modules.system.entity.SysUser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.Collections; import java.util.List; @Slf4j @Api(tags = "DNC部门管理") @RestController @RequestMapping("/ucenter/depart") public class DepartmentController { @Autowired private IDepartmentService departmentService; @AutoLog(value = "DNC部门管理-添加部门信息") @ApiOperation(value = "DNC部门管理-添加部门信息", notes = "DNC部门管理-添加部门信息") @PostMapping("/add") public ResponseResult addDepartment(@RequestBody Department department) { boolean b = departmentService.addDepartment(department); if(b) { return new ResponseResult(CommonCode.SUCCESS); } return new ResponseResult(CommonCode.FAIL); } @AutoLog(value = "DNC部门管理-修改部门") @ApiOperation(value = "DNC部门管理-修改部门", notes = "DNC部门管理-修改部门") @PutMapping("/edit/{id}") public ResponseResult editDepartment(@PathVariable("id") String id,@RequestBody Department department) { boolean b = departmentService.editDepartment(id,department); if(b) { return new ResponseResult(CommonCode.SUCCESS); } return new ResponseResult(CommonCode.FAIL); } @AutoLog(value = "DNC部门管理-分页查询") @ApiOperation(value = "DNC部门管理-分页查询", notes = "DNC部门管理-分页查询") @GetMapping("/find/page/{page}/{size}") public QueryPageResponseResult findPageList(@PathVariable("page") int page, @PathVariable("size") int size, DepartmentRequest departmentRequest) { return departmentService.findPageList(page,size,departmentRequest); } @AutoLog(value = "DNC部门管理-获取所有列表,按层级") @ApiOperation(value = "DNC部门管理-获取所有列表,按层级", notes = "DNC部门管理-获取所有列表,按层级") @GetMapping("/load/tree") public QueryListResponseResult loadTree() { List tree = departmentService.loadTree(); if(tree == null) tree = Collections.emptyList(); return new QueryListResponseResult(CommonCode.SUCCESS, tree); } @AutoLog(value = "DNC部门管理-删除 部门") @ApiOperation(value = "DNC部门管理-删除 部门", notes = "DNC部门管理-删除 部门") @DeleteMapping("/delete") public ResponseResult deleteDepartment(@RequestParam("id") String id) { boolean b = departmentService.deleteDepartmentById(id); if(b) { return new ResponseResult(CommonCode.SUCCESS); } return new ResponseResult(CommonCode.FAIL); } @AutoLog(value = "DNC部门管理-获取用户未分配的部门列表") @ApiOperation(value = "DNC部门管理-获取用户未分配的部门列表", notes = "DNC部门管理-获取用户未分配的部门列表") @GetMapping("/perm/select/non/{userId}") public QueryListResponseResult getUserNonPermDepart(@PathVariable("userId") String userId) { List list = departmentService.getUserNonPermDepart(userId); if(list == null) list = Collections.emptyList(); return new QueryListResponseResult<>(CommonCode.SUCCESS, list); } @AutoLog(value = "DNC部门管理-获取用户已分配的部门列表") @ApiOperation(value = "DNC部门管理-获取用户已分配的部门列表", notes = "DNC部门管理-获取用户已分配的部门列表") @GetMapping("/perm/select/{userId}") public QueryListResponseResult getUserPermDepart(@PathVariable("userId") String userId) { List list = departmentService.getUserPermDepart(userId); if(list == null) list = Collections.emptyList(); return new QueryListResponseResult<>(CommonCode.SUCCESS, list); } @AutoLog(value = "DNC部门管理-获取部门未指定的审批人") @ApiOperation(value = "DNC部门管理-获取部门未指定的审批人", notes = "DNC部门管理-获取部门未指定的审批人") @GetMapping("/approve/select/non/{departId}") public QueryListResponseResult getUserNonApproveDepart(@PathVariable("departId") String departId) { List list = departmentService.getUserNonApproveDepart(departId); if(list == null) list = Collections.emptyList(); return new QueryListResponseResult<>(CommonCode.SUCCESS, list); } @AutoLog(value = "DNC部门管理-获取部门已指定的审批人") @ApiOperation(value = "DNC部门管理-获取部门已指定的审批人", notes = "DNC部门管理-获取部门已指定的审批人") @GetMapping("/approve/select/{departId}") public QueryListResponseResult getUserApproveDepart(@PathVariable("departId") String departId) { List list = departmentService.getUserApproveDepart(departId); if(list == null) list = Collections.emptyList(); return new QueryListResponseResult<>(CommonCode.SUCCESS, list); } @AutoLog(value = "DNC部门管理-增加部门审批人") @ApiOperation(value = "DNC部门管理-增加部门审批人", notes = "DNC部门管理-增加部门审批人") @PostMapping("/assign/add/approve/user/{departId}/{relativeFlag}") public ResponseResult assignAddApproveUser(@PathVariable("departId") String departId, @PathVariable("relativeFlag") Integer relativeFlag, @RequestBody String[] userIds) { boolean b = departmentService.assignAddApproveUser(departId, relativeFlag, userIds); if(b) { return new ResponseResult(CommonCode.SUCCESS); } return new ResponseResult(CommonCode.FAIL); } @AutoLog(value = "DNC部门管理-移除部门审批人") @ApiOperation(value = "DNC部门管理-移除部门审批人", notes = "DNC部门管理-移除部门审批人") @PostMapping("/assign/remove/approve/user/{departId}/{relativeFlag}") public ResponseResult assignRemoveApproveUser(@PathVariable("departId") String departId, @PathVariable("relativeFlag") Integer relativeFlag, @RequestBody String[] userIds) { boolean b = departmentService.assignRemoveApproveUser(departId, relativeFlag, userIds); if(b) { return new ResponseResult(CommonCode.SUCCESS); } return new ResponseResult(CommonCode.FAIL); } @AutoLog(value = "DNC部门管理-获取部门List") @ApiOperation(value = "DNC部门管理-获取部门List", notes = "DNC部门管理-获取部门List") @GetMapping("/list/all") public QueryListResponseResult getDepartList() { List list = departmentService.list(); if(list == null) list = Collections.emptyList(); return new QueryListResponseResult<>(CommonCode.SUCCESS, list); } }