package com.huimv.guowei.admin.controller; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.huimv.guowei.admin.common.utils.Result; import com.huimv.guowei.admin.entity.EnvWarningThreshold; import com.huimv.guowei.admin.service.IEnvWarningInfoService; import com.huimv.guowei.admin.service.IEnvWarningThresholdService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import java.util.Map; /** *

* 前端控制器 *

* * @author author * @since 2023-06-01 */ @RestController @RequestMapping("/env-warning-threshold") public class EnvWarningThresholdController { @Autowired private IEnvWarningThresholdService envWarningThresholdService; @PostMapping("/saveThreshold") public Result saveThreshold(@RequestBody Map paramsMap){ String farmId = paramsMap.get("farmId"); String maxTem = paramsMap.get("maxTem"); String minTem = paramsMap.get("minTem"); String maxHum = paramsMap.get("maxHum"); String minHum = paramsMap.get("minHum"); EnvWarningThreshold envWarningThreshold = new EnvWarningThreshold(); envWarningThreshold.setFarmId(Integer.parseInt(farmId)); envWarningThreshold.setMaxHum(maxHum); envWarningThreshold.setMinHum(minHum); envWarningThreshold.setMaxTem(maxTem); envWarningThreshold.setMinTem(minTem); envWarningThresholdService.saveOrUpdate(envWarningThreshold,new UpdateWrapper().eq("farm_id",farmId)); return Result.SUCCESS(); } }