Fixiaobai
2023-08-28 1865de1cd0255f7c42a326018a8cc3b5a1ee5253
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
package com.yuanchu.limslaboratory.controller;
 
import com.yuanchu.limslaboratory.annotation.AuthHandler;
import com.yuanchu.limslaboratory.pojo.Organizational;
import com.yuanchu.limslaboratory.service.OrganizationalService;
import com.yuanchu.limslaboratory.utils.MyUtil;
import com.yuanchu.limslaboratory.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
 
import java.util.List;
import java.util.Map;
 
/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 江苏鵷雏网络科技有限公司
 * @since 2023-08-23 01:13:37
 */
@Api(tags = "实验室管理-->组织架构")
@RestController
@RequestMapping("/organizational")
public class OrganizationalController {
 
    @Autowired
    private OrganizationalService organizationalService;
 
    @ApiOperation(value = "侧边栏树展开")
    @GetMapping("/list")
    @AuthHandler
    public Result<?> getFourLevelInformation() {
        List<Map<String, Object>> organizationalTree = organizationalService.OrganizationalTree();
        return Result.success(organizationalTree);
    }
 
    @ApiOperation(value = "根据点击Id查询部门")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(value = "部门ID", name = "departmentId", dataTypeClass = Integer.class)
    })
    @GetMapping("/table")
    @AuthHandler
    public Result<?> getDepartmentListTable(Integer departmentId) {
        List<Map<String, Object>> departmentListTable = organizationalService.getDepartmentListTable(departmentId);
        return Result.success(departmentListTable);
    }
 
    @ApiOperation(value = "添加部门")
    @PostMapping("/add")
    @AuthHandler
    public Result<?> addDepartment(@RequestBody @Validated Organizational organizational) {
        Integer addDepartment = organizationalService.addDepartment(organizational);
        if (addDepartment >= 1){
            return Result.success("添加成功!");
        }
        return Result.fail("添加失败!");
    }
 
    @ApiOperation(value = "修改部门")
    @PutMapping("/update")
    @AuthHandler
    public Result<?> updateDepartment(Integer id, @RequestBody @Validated Organizational organizational) {
        Integer addDepartment = organizationalService.updateDepartment(id, organizational);
        if (addDepartment >= 1){
            return Result.success("更新成功!");
        }
        return Result.fail("更新失败!");
    }
 
    @ApiOperation(value = "删除部门")
    @DeleteMapping("/delete")
    @AuthHandler
    public Result<?> deleteDepartment(String ids) {
        organizationalService.deleteDepartment(ids);
        return Result.success("删除成功!");
    }
}