WeatherStationInfoController.java 4.2 KB

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