危化品全生命周期管理后端
kongzy
2024-08-22 0c73654f55844e34772732914af8cc1e247aab63
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
package com.gkhy.hazmat.admin.controller.system;
 
 
import com.gkhy.hazmat.common.annotation.RepeatSubmit;
import com.gkhy.hazmat.common.api.CommonResult;
import com.gkhy.hazmat.system.domain.SysDept;
import com.gkhy.hazmat.system.service.SysDeptService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.*;
 
/**
 * <p>
 * 部门表 前端控制器
 * </p>
 *
 * @author kzy
 * @since 2024-08-05 14:41:40
 */
@Api(tags = "部门前端控制器")
@RestController
@RequestMapping("/system/dept")
public class SysDeptController {
    @Autowired
    private SysDeptService deptService;
 
    @PreAuthorize("hasAnyAuthority('hazmat:manage:system','hazmat:manage:company','hazmat:manage:common')")
    @ApiOperation(value = "部门列表(树形结构)")
    @GetMapping("/treeList")
    public CommonResult list(SysDept dept){
        return CommonResult.success(deptService.selectDeptTreeList(dept));
    }
 
 
    @RepeatSubmit
    @PreAuthorize("hasAnyAuthority('hazmat:manage:company')")
    @ApiOperation(value = "新增部门")
    @PostMapping
    public CommonResult add(@Validated @RequestBody SysDept dept){
        return CommonResult.success(deptService.insertDept(dept));
    }
 
    @PreAuthorize("hasAnyAuthority('hazmat:manage:company')")
    @RepeatSubmit
    @ApiOperation(value = "编辑部门")
    @PutMapping
    public CommonResult edit(@Validated @RequestBody SysDept dept){
        return CommonResult.success(deptService.updateDept(dept));
    }
 
    @PreAuthorize("hasAnyAuthority('hazmat:manage:company')")
    @RepeatSubmit
    @ApiOperation(value = "删除部门")
    @PutMapping("/{deptId}")
    public CommonResult delete(@PathVariable(value = "deptId" ,required = true)Long deptId){
        return CommonResult.success(deptService.deleteDeptById(deptId));
    }
}