¶Ô±ÈÐÂÎļþ |
| | |
| | | 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."); |
| | | } |
| | | } |