燕山石化溯源三维电子沙盘-【后端】-服务
1
13693261870
2023-07-27 093a6b0549f5f1ed921d7bc4cfb5d43619c148ae
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
package com.yssh.controller;
 
import com.yssh.utils.CacheUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
 
import java.util.Date;
import java.util.List;
 
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yssh.entity.AlertConfig;
import com.yssh.service.AlertConfigService;
import com.yssh.utils.Result;
 
import javax.annotation.Resource;
 
@Api(tags="告警配置")
@RestController
@RequestMapping("/config")
@SuppressWarnings("rawtypes")
public class AlertConfigController {
    @Resource
    private AlertConfigService alertConfigService;
 
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "查询所有告警配置数据", notes = "查询所有告警配置数据")
    @GetMapping("/all")
    public Result getAll() {
        List<AlertConfig> list = alertConfigService.getAll();
        return Result.OK(list);
    }
 
    @ApiOperationSupport(order = 2)
    @ApiImplicitParam(name = "id", value = "告警配置编号", required = true, type = "int")
    @ApiOperation(value = "根据编号查询告警配置数据详情", notes = "根据编号查询告警配置数据详情")
    @GetMapping("/query/{id}")
    public Result query(@PathVariable("id") Integer id) {
        List<AlertConfig> data = alertConfigService.query(id);
        return Result.OK(data);
    }
 
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "更新告警配置数据", notes = "根据告警配置编号修改告警配置数据内容")
    @PutMapping
    public Result update(@RequestBody AlertConfig config) {
        int row = alertConfigService.update(config);
        if (row == 0) {
            return Result.error("更新失败");
        }
        return Result.OK("更新成功");
    }
 
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "新增告警配置数据", notes = "新增告警配置详情数据")
    @PostMapping
    public Result add(@RequestBody AlertConfig alert) {
        int row = alertConfigService.insert(alert);
        if (row == 0) {
            return Result.error("新增失败");
        }
        return Result.OK("新增成功");
    }
 
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "删除告警配置数据", notes = "删除告警配置详情数据")
    @DeleteMapping("/{id}")
    public Result delete(@PathVariable Integer id) {
        int row = alertConfigService.delete(id);
        if (row == 0) {
            return Result.error("删除失败");
        }
        return Result.OK("删除成功");
    }
 
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "清除缓存", notes = "清除缓存")
    @GetMapping("/clearCache")
    public Result clearCache() {
        CacheUtils.clear();
 
        return Result.OK("success.");
    }
}