WeatherLookController.java 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package com.jiayue.biz.controller;
  2. import com.jiayue.biz.domain.WeatherLook;
  3. import com.jiayue.biz.service.EnvironmentalDataService;
  4. import com.jiayue.biz.service.WeatherLookService;
  5. import com.jiayue.common.annotation.Log;
  6. import com.jiayue.common.core.controller.BaseController;
  7. import com.jiayue.common.core.domain.AjaxResult;
  8. import com.jiayue.common.core.page.TableDataInfo;
  9. import com.jiayue.common.enums.BusinessType;
  10. import lombok.RequiredArgsConstructor;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.web.bind.annotation.*;
  13. import java.util.ArrayList;
  14. import java.util.HashMap;
  15. import java.util.List;
  16. import java.util.stream.Collectors;
  17. @RequiredArgsConstructor(onConstructor_ = @Autowired)
  18. @RestController
  19. @RequestMapping("/weatherLook")
  20. public class WeatherLookController extends BaseController {
  21. private final WeatherLookService weatherLookService;
  22. private final EnvironmentalDataService environmentalDataService;
  23. /**
  24. * 查询环境监测仪信息列表
  25. */
  26. @GetMapping("/list")
  27. public TableDataInfo list() {
  28. List<WeatherLook> weatherLooks = weatherLookService.list();
  29. return getDataTable(weatherLooks);
  30. }
  31. /**
  32. * 新增环境监测仪信息
  33. */
  34. @Log(title = "环境监测仪信息", businessType = BusinessType.INSERT)
  35. @PostMapping
  36. public AjaxResult add(@RequestBody WeatherLook weatherLook) {
  37. return toAjax(environmentalDataService.saveWeather(weatherLook) ? 1 : 0);
  38. }
  39. /**
  40. * 修改环境监测仪信息
  41. */
  42. @Log(title = "环境监测仪信息", businessType = BusinessType.UPDATE)
  43. @PutMapping
  44. public AjaxResult edit(@RequestBody WeatherLook weatherLook) {
  45. return toAjax(weatherLookService.updateById(weatherLook) ? 1 : 0);
  46. }
  47. /**
  48. * 删除环境监测仪信息
  49. */
  50. @Log(title = "环境监测仪信息", businessType = BusinessType.DELETE)
  51. @DeleteMapping("/{ids}")
  52. public AjaxResult remove(@PathVariable String ids) {
  53. List<WeatherLook> weatherLookList = weatherLookService.list().stream().filter(w -> w.getId().equals(ids)).collect(Collectors.toList());
  54. return toAjax(environmentalDataService.deleteWeather(ids,weatherLookList) ? 1 : 0);
  55. }
  56. @GetMapping("/infoList")
  57. public AjaxResult infoList() {
  58. List<WeatherLook> weatherLookList = weatherLookService.list();
  59. List list = new ArrayList();
  60. for(WeatherLook weatherLook : weatherLookList){
  61. HashMap map = new HashMap();
  62. map.put("no",weatherLook.getWeatherLookNo());
  63. map.put("name",weatherLook.getWeatherLookName());
  64. list.add(map);
  65. }
  66. return AjaxResult.success(list);
  67. }
  68. }