123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- package com.jiayue.biz.controller;
- import com.jiayue.biz.domain.WeatherLook;
- import com.jiayue.biz.service.EnvironmentalDataService;
- import com.jiayue.biz.service.WeatherLookService;
- import com.jiayue.common.annotation.Log;
- import com.jiayue.common.core.controller.BaseController;
- import com.jiayue.common.core.domain.AjaxResult;
- import com.jiayue.common.core.page.TableDataInfo;
- import com.jiayue.common.enums.BusinessType;
- import lombok.RequiredArgsConstructor;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import java.util.stream.Collectors;
- @RequiredArgsConstructor(onConstructor_ = @Autowired)
- @RestController
- @RequestMapping("/weatherLook")
- public class WeatherLookController extends BaseController {
- private final WeatherLookService weatherLookService;
- private final EnvironmentalDataService environmentalDataService;
- /**
- * 查询环境监测仪信息列表
- */
- @GetMapping("/list")
- public TableDataInfo list() {
- List<WeatherLook> weatherLooks = weatherLookService.list();
- return getDataTable(weatherLooks);
- }
- /**
- * 新增环境监测仪信息
- */
- @Log(title = "环境监测仪信息", businessType = BusinessType.INSERT)
- @PostMapping
- public AjaxResult add(@RequestBody WeatherLook weatherLook) {
- return toAjax(environmentalDataService.saveWeather(weatherLook) ? 1 : 0);
- }
- /**
- * 修改环境监测仪信息
- */
- @Log(title = "环境监测仪信息", businessType = BusinessType.UPDATE)
- @PutMapping
- public AjaxResult edit(@RequestBody WeatherLook weatherLook) {
- return toAjax(weatherLookService.updateById(weatherLook) ? 1 : 0);
- }
- /**
- * 删除环境监测仪信息
- */
- @Log(title = "环境监测仪信息", businessType = BusinessType.DELETE)
- @DeleteMapping("/{ids}")
- public AjaxResult remove(@PathVariable String ids) {
- List<WeatherLook> weatherLookList = weatherLookService.list().stream().filter(w -> w.getId().equals(ids)).collect(Collectors.toList());
- return toAjax(environmentalDataService.deleteWeather(ids,weatherLookList) ? 1 : 0);
- }
- @GetMapping("/infoList")
- public AjaxResult infoList() {
- List<WeatherLook> weatherLookList = weatherLookService.list();
- List list = new ArrayList();
- for(WeatherLook weatherLook : weatherLookList){
- HashMap map = new HashMap();
- map.put("no",weatherLook.getWeatherLookNo());
- map.put("name",weatherLook.getWeatherLookName());
- list.add(map);
- }
- return AjaxResult.success(list);
- }
- }
|