package com.huimv.environ.env.environ.controller;

import com.huimv.common.utils.Result;
import com.huimv.environ.env.environ.service.IEnviron;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;

/**
 * @Project : huimv.shiwan
 * @Package : com.huimv.biosafety.uface.controller
 * @Description : TODO
 * @Version : 1.0
 * @Author : ZhuoNing
 * @Create : 2020-12-25
 **/
@RestController
@RequestMapping(value = "/environ")
public class EnvironController {
    @Autowired
    private IEnviron environ;

    /**
     * @Method      : getLastEnviron
     * @Description : 返回最新环保记录
     * @Params      : []
     * @Return      : java.lang.String
     * 
     * @Author      : ZhuoNing
     * @Date        : 2021/12/2       
     * @Time        : 22:25
     */
    @RequestMapping(value = "/getLastEnviron",method = RequestMethod.GET)
    public Result getLastEnviron(@RequestParam(value = "farmId",required = true) Integer farmId){
        //
        return environ.getLastEnviron(farmId);
    }

    /**
     * @Method      : getLastSevenDayEnviron
     * @Description : 获取最近N天环保数据集合
     * @Params      : [farmId,days]
     * @Return      : com.huimv.common.result.Result
     * 
     * @Author      : ZhuoNing
     * @Date        : 2021/12/3       
     * @Time        : 20:51
     */
    @RequestMapping(value = "/getLastSevenDayEnviron",method = RequestMethod.GET)
    public Result getLastSevenDayEnviron(@RequestParam(value = "farmId",required = true) Integer farmId,@RequestParam(value = "days",required = true) Integer days) throws ParseException {
        if(days == null){
            days = 7;
        }
        //
        return environ.getLastSevenDayEnviron(farmId,days);
    }
}
