From a9f99d3f074472e1e16ec6109e5d819ca8dcf4d0 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期二, 31 十月 2023 15:51:15 +0800 Subject: [PATCH] 添加判断是否含有污染源的接口 --- src/main/java/com/yssh/controller/AlertConfigController.java | 82 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 82 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/yssh/controller/AlertConfigController.java b/src/main/java/com/yssh/controller/AlertConfigController.java new file mode 100644 index 0000000..026b20f --- /dev/null +++ b/src/main/java/com/yssh/controller/AlertConfigController.java @@ -0,0 +1,82 @@ +package com.yssh.controller; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; + +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("鍒犻櫎鎴愬姛"); + } +} -- Gitblit v1.9.3