package com.chinaitop.depot.intelligent.weather.controller;

import com.chinaitop.depot.intelligent.basicdata.model.TNtinfo;
import com.chinaitop.depot.intelligent.basicdata.service.GasService;
import com.chinaitop.depot.intelligent.weather.model.TWeatherhsitory;
import com.chinaitop.depot.intelligent.weather.model.TWertherinfo;
import com.chinaitop.depot.intelligent.weather.service.WeatherManagerService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.unissoft.model.ResponseEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping(value = "/intelligents/weather")
@Api(value = "WeatherManagerController", description = "气象管理控制类")
public class WeatherManagerController {

    @Resource
    private WeatherManagerService weatherManagerService;

    @RequestMapping(value = "/getList", method = RequestMethod.GET)
    @ApiOperation(value = "查询 气象检测 信息列表", notes = "查询 气象检测 信息列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页码", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页条数", paramType = "query"),
            @ApiImplicitParam(name = "vqxzname", value = "气象站名称", paramType = "query"),
            @ApiImplicitParam(name = "searchStartDate", value = "开始时间", paramType = "query"),
            @ApiImplicitParam(name = "searchEndDate", value = "结束时间", paramType = "query")
    })
    public ResponseEntity<PageInfo<TWeatherhsitory>> getList(Integer pageNum, Integer pageSize, String vqxzname, String searchStartDate, String searchEndDate) {
        List<TWeatherhsitory> list = null;
        try {
            if (null != pageNum && null != pageSize) {
                PageHelper.startPage(pageNum, pageSize);
            }
            list = weatherManagerService.getList(vqxzname,searchStartDate,searchEndDate);
        } catch (Exception e) {
            e.printStackTrace();
            return ResponseEntity.failed("查询气象列表失败");
        }
        PageInfo<TWeatherhsitory> pageInfo = new PageInfo<TWeatherhsitory>(list);
        return ResponseEntity.ok(pageInfo);
    }
}
