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.");
|
}
|
}
|