package com.huimv.produce.warning.controller;


import cn.hutool.core.util.ObjectUtil;
import com.huimv.common.token.TokenSign;
import com.huimv.common.utils.Result;
import com.huimv.common.utils.ResultCode;
import com.huimv.produce.warning.entity.SysThreshold;
import com.huimv.produce.warning.service.ISysThresholdService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author astupidcoder
 * @since 2021-11-30
 */
@RestController
@RequestMapping("/threshold")
@Slf4j
public class SysThresholdController {
    @Autowired
    private ISysThresholdService thresholdService;

    @PostMapping("/addThreshold")
    public Result addThreshold(HttpServletRequest request,@RequestBody Map<String,String> paramsMap){
        return thresholdService.addThreshold(request,paramsMap);
    }

    //阈值
    @PostMapping("/getThreshold")
    public Result getThreshold(@RequestBody  Map<String,String> paramsMap, HttpServletRequest request){
        return thresholdService.getThreshold(request,paramsMap);
    }

    @PostMapping("/getThresholdByFarmId")
    public Result getThresholdByFarmId(@RequestBody  Map<String,String> paramsMap){
        String farmId = paramsMap.get("farmId");
        log.info("farmId="+farmId);
        return new Result(ResultCode.SUCCESS,thresholdService.getById(farmId));
    }

    @PostMapping("/listWarningInfoWeater")
    public Result listWarningInfoWeater(@RequestBody Map<String, String> map ) {
        return thresholdService.listWarningInfoWeater(map);
    }
}
