WeatherStationInfoController.java 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. package com.jiayue.ipfcst.console.controller;
  2. import com.jiayue.ipfcst.aop.SaveValidate;
  3. import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
  4. import com.jiayue.ipfcst.common.data.entity.WeatherStationInfo;
  5. import com.jiayue.ipfcst.console.service.WeatherStationInfoService;
  6. import lombok.SneakyThrows;
  7. import lombok.extern.slf4j.Slf4j;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.data.domain.Page;
  10. import org.springframework.web.bind.annotation.*;
  11. import java.util.List;
  12. /**
  13. * 环境监测仪restful接口
  14. *
  15. * @author tl
  16. * @version 3.0
  17. * @since 2020/6/7 11:29
  18. */
  19. @RestController
  20. @RequestMapping("/weatherStationInfo")
  21. @Slf4j
  22. public class WeatherStationInfoController {
  23. private final WeatherStationInfoService weatherStationInfoService;
  24. @Autowired
  25. public WeatherStationInfoController(WeatherStationInfoService weatherStationInfoService) {
  26. this.weatherStationInfoService = weatherStationInfoService;
  27. }
  28. /**
  29. * 新增环境监测仪
  30. *
  31. * @param weatherStationInfo 参数
  32. * @return 执行结果
  33. */
  34. @SneakyThrows
  35. @SaveValidate
  36. @PostMapping()
  37. public ResponseVO add(@RequestBody WeatherStationInfo weatherStationInfo) {
  38. try {
  39. this.weatherStationInfoService.add(weatherStationInfo);
  40. return ResponseVO.success(1);
  41. } catch (Exception ex) {
  42. log.error("系统错误" + ex);
  43. return ResponseVO.error(ex);
  44. }
  45. }
  46. /**
  47. * 修改环境监测仪
  48. *
  49. * @param weatherStationInfo 参数
  50. * @return 执行结果
  51. */
  52. @SneakyThrows
  53. @SaveValidate
  54. @PutMapping()
  55. public ResponseVO update(@RequestBody WeatherStationInfo weatherStationInfo) {
  56. try {
  57. this.weatherStationInfoService.update(weatherStationInfo);
  58. return ResponseVO.success(1);
  59. } catch (Exception ex) {
  60. log.error("系统错误" + ex);
  61. return ResponseVO.error(ex);
  62. }
  63. }
  64. /**
  65. * 获取环境监测仪
  66. *
  67. * @param weatherStationInfo 参数
  68. * @return 执行结果
  69. */
  70. @SneakyThrows
  71. @GetMapping("/ById")
  72. public ResponseVO get(@RequestBody WeatherStationInfo weatherStationInfo) {
  73. try {
  74. weatherStationInfo = this.weatherStationInfoService.get(weatherStationInfo.getId());
  75. return ResponseVO.success(weatherStationInfo);
  76. } catch (Exception ex) {
  77. log.error("系统错误" + ex);
  78. return ResponseVO.error(ex);
  79. }
  80. }
  81. /**
  82. * 删除环境监测仪
  83. *
  84. * @param id 参数
  85. * @return 执行结果
  86. */
  87. @SneakyThrows
  88. @SaveValidate
  89. @DeleteMapping("/{id}")
  90. public ResponseVO delete(@PathVariable Integer id) {
  91. try {
  92. this.weatherStationInfoService.delete(id);
  93. return ResponseVO.success(1);
  94. } catch (Exception ex) {
  95. log.error("系统错误" + ex);
  96. return ResponseVO.error(ex);
  97. }
  98. }
  99. /**RequestParams
  100. * 获取环境监测仪
  101. *
  102. * @param stationCode 参数
  103. * @return 执行结果
  104. */
  105. @GetMapping(value = "/{stationCode}")
  106. public ResponseVO getAll(@PathVariable("stationCode") String stationCode) {
  107. try {
  108. List<WeatherStationInfo> weatherStationInfoPage = this.weatherStationInfoService.get(stationCode);
  109. return ResponseVO.success(weatherStationInfoPage);
  110. } catch (Exception ex) {
  111. log.error("系统错误" + ex);
  112. return ResponseVO.error(ex);
  113. }
  114. }
  115. /**
  116. * 获取环境监测仪
  117. *
  118. * @return 执行结果
  119. */
  120. @GetMapping()
  121. public ResponseVO getAll() {
  122. try {
  123. List<WeatherStationInfo> list = this.weatherStationInfoService.getAll();
  124. return ResponseVO.success(list);
  125. } catch (Exception ex) {
  126. log.error("系统错误" + ex);
  127. return ResponseVO.error(ex);
  128. }
  129. }
  130. }