危化品全生命周期管理后端
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
package com.gkhy.hazmat.admin.controller.system;
 
import com.gkhy.hazmat.common.api.CommonResult;
import com.gkhy.hazmat.system.domain.SysConfig;
import com.gkhy.hazmat.system.service.SysConfigService;
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.*;
 
@Api(tags = "系统配置前端控制器")
@RestController
@RequestMapping("/system/config")
public class SysConfigController {
    @Autowired
    private SysConfigService configService;
 
    @PreAuthorize("hasAnyAuthority('hazmat:manage:system')")
    @ApiOperation(value = "配置列表")
    @GetMapping("/list")
    public CommonResult list(SysConfig config){
        return CommonResult.success(configService.selectConfigList(config));
    }
 
    @PreAuthorize("hasAnyAuthority('hazmat:manage:system')")
    @ApiOperation(value = "新增配置")
    @PostMapping
    public CommonResult add(@Validated @RequestBody SysConfig config){
        return CommonResult.success(configService.insertConfig(config));
    }
 
    @PreAuthorize("hasAnyAuthority('hazmat:manage:system')")
    @ApiOperation(value = "更新配置")
    @PutMapping
    public CommonResult edit(@Validated @RequestBody SysConfig config){
        return CommonResult.success(configService.updateConfig(config));
    }
 
    @PreAuthorize("hasAnyAuthority('hazmat:manage:system')")
    @ApiOperation(value = "删除配置")
    @DeleteMapping(value = "/{configId}")
    public CommonResult remove(@PathVariable Long configId){
        configService.deleteConfigById(configId);
        return CommonResult.success();
    }
 
    @PreAuthorize("hasAnyAuthority('hazmat:manage:company','hazmat:manage:common')")
    @ApiOperation(value = "查询当前用户公司配置")
    @GetMapping(value = "/getConfigByUser")
    public CommonResult getConfigByUser(){
        return CommonResult.success(configService.getConfigByUser());
    }
}