123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- package com.jiayue.ipfcst.console.controller;
- import com.jiayue.ipfcst.aop.BaseInfoImage;
- import com.jiayue.ipfcst.aop.SaveValidate;
- import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
- import com.jiayue.ipfcst.common.data.constant.enums.EquipmentTypeEnum;
- import com.jiayue.ipfcst.common.data.entity.WeatherStationInfo;
- import com.jiayue.ipfcst.console.service.WeatherStationInfoService;
- import lombok.SneakyThrows;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.data.domain.Page;
- import org.springframework.web.bind.annotation.*;
- import java.util.List;
- /**
- * 环境监测仪restful接口
- *
- * @author tl
- * @version 3.0
- * @since 2020/6/7 11:29
- */
- @RestController
- @RequestMapping("/weatherStationInfo")
- @Slf4j
- public class WeatherStationInfoController {
- private final WeatherStationInfoService weatherStationInfoService;
- @Autowired
- public WeatherStationInfoController(WeatherStationInfoService weatherStationInfoService) {
- this.weatherStationInfoService = weatherStationInfoService;
- }
- /**
- * 新增环境监测仪
- *
- * @param weatherStationInfo 参数
- * @return 执行结果
- */
- @SneakyThrows
- @SaveValidate
- @PostMapping()
- @BaseInfoImage(title = "WeatherStationInfo")
- public ResponseVO add(@RequestBody WeatherStationInfo weatherStationInfo) {
- try {
- this.weatherStationInfoService.add(weatherStationInfo);
- return ResponseVO.success(1);
- } catch (Exception ex) {
- log.error("系统错误" + ex);
- return ResponseVO.error(ex);
- }
- }
- /**
- * 修改环境监测仪
- *
- * @param weatherStationInfo 参数
- * @return 执行结果
- */
- @SneakyThrows
- @SaveValidate
- @PutMapping()
- @BaseInfoImage(title = "WeatherStationInfo")
- public ResponseVO update(@RequestBody WeatherStationInfo weatherStationInfo) {
- try {
- this.weatherStationInfoService.update(weatherStationInfo);
- return ResponseVO.success(1);
- } catch (Exception ex) {
- log.error("系统错误" + ex);
- return ResponseVO.error(ex);
- }
- }
- /**
- * 获取环境监测仪
- *
- * @param weatherStationInfo 参数
- * @return 执行结果
- */
- @SneakyThrows
- @GetMapping("/ById")
- public ResponseVO get(@RequestBody WeatherStationInfo weatherStationInfo) {
- try {
- weatherStationInfo = this.weatherStationInfoService.get(weatherStationInfo.getId());
- return ResponseVO.success(weatherStationInfo);
- } catch (Exception ex) {
- log.error("系统错误" + ex);
- return ResponseVO.error(ex);
- }
- }
- /**
- * 删除环境监测仪
- *
- * @param id 参数
- * @return 执行结果
- */
- @SneakyThrows
- @SaveValidate
- @DeleteMapping("/{id}")
- @BaseInfoImage(title = "WeatherStationInfo")
- public ResponseVO delete(@PathVariable Integer id) {
- try {
- this.weatherStationInfoService.delete(id);
- return ResponseVO.success(1);
- } catch (Exception ex) {
- log.error("系统错误" + ex);
- return ResponseVO.error(ex);
- }
- }
- /**
- * 获取环境监测仪
- *
- * @param page 参数
- * @return 执行结果
- */
- @GetMapping(value = "/{page}/{size}")
- public ResponseVO getAll(@PathVariable("page") Integer page, @PathVariable("size") Integer size) {
- try {
- WeatherStationInfo weatherStationInfo = new WeatherStationInfo();
- Page<WeatherStationInfo> weatherStationInfoPage = this.weatherStationInfoService.get(weatherStationInfo, page, size);
- return ResponseVO.success(weatherStationInfoPage);
- } catch (Exception ex) {
- log.error("系统错误" + ex);
- return ResponseVO.error(ex);
- }
- }
- /**
- * 获取环境监测仪
- *
- * @return 执行结果
- */
- @GetMapping()
- public ResponseVO getAll() {
- try {
- List<WeatherStationInfo> list = this.weatherStationInfoService.getAll();
- return ResponseVO.success(list);
- } catch (Exception ex) {
- log.error("系统错误" + ex);
- return ResponseVO.error(ex);
- }
- }
- }
|