lyh
3 天以前 2ab86210fb27787cb1be8976286b9b827f90997f
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
package com.lxzn.ucenter.controller;
 
import com.lxzn.api.ucenter.DepartmentControllerApi;
import com.lxzn.framework.domain.ucenter.Department;
import com.lxzn.framework.domain.ucenter.User;
import com.lxzn.framework.domain.ucenter.request.DepartmentRequest;
import com.lxzn.framework.model.response.*;
import com.lxzn.ucenter.service.IDepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.Collections;
import java.util.List;
 
@RestController
@RequestMapping("/ucenter/depart")
public class DepartmentController implements DepartmentControllerApi {
    @Autowired
    private IDepartmentService departmentService;
 
    @Override
    @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);
    }
 
    @Override
    @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);
    }
 
    @Override
    @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);
    }
 
    @Override
    @GetMapping("/load/tree")
    public QueryListResponseResult<CommonJsonTree> loadTree() {
        List<CommonJsonTree> tree = departmentService.loadTree();
        if(tree == null)
            tree = Collections.emptyList();
        return new QueryListResponseResult(CommonCode.SUCCESS, tree);
    }
 
    @Override
    @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);
    }
 
    @Override
    @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);
    }
 
    @Override
    @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);
    }
 
    @Override
    @GetMapping("/approve/select/non/{departId}")
    public QueryListResponseResult<User> getUserNonApproveDepart(@PathVariable("departId") String departId) {
        List<User> list = departmentService.getUserNonApproveDepart(departId);
        if(list == null)
            list = Collections.emptyList();
        return new QueryListResponseResult<>(CommonCode.SUCCESS, list);
    }
 
    @Override
    @GetMapping("/approve/select/{departId}")
    public QueryListResponseResult<User> getUserApproveDepart(@PathVariable("departId") String departId) {
        List<User> list = departmentService.getUserApproveDepart(departId);
        if(list == null)
            list = Collections.emptyList();
        return new QueryListResponseResult<>(CommonCode.SUCCESS, list);
    }
 
    @Override
    @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);
    }
 
    @Override
    @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);
    }
 
    @Override
    @GetMapping("/list/all")
    public QueryListResponseResult<Department> getDepartList() {
        List<Department> list = departmentService.list();
        if(list == null)
            list = Collections.emptyList();
        return new QueryListResponseResult<>(CommonCode.SUCCESS, list);
    }
}