lyh
2025-01-13 76e6eaff3a5be5f73ddb90b9169381dc46503ccd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
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<Department> 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<CommonJsonTree> loadTree() {
        List<CommonJsonTree> 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<Department> getUserNonPermDepart(@PathVariable("userId") String userId) {
        List<Department> 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<Department> getUserPermDepart(@PathVariable("userId") String userId) {
        List<Department> 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<SysUser> getUserNonApproveDepart(@PathVariable("departId") String departId) {
        List<SysUser> 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<SysUser> getUserApproveDepart(@PathVariable("departId") String departId) {
        List<SysUser> 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<Department> getDepartList() {
        List<Department> list = departmentService.list();
        if(list == null)
            list = Collections.emptyList();
        return new QueryListResponseResult<>(CommonCode.SUCCESS, list);
    }
}