Newer
Older
huludao / src / main / java / com / newfiber / api / pc / controller / weather / GaofenWeatherController.java
package com.newfiber.api.pc.controller.weather;

import com.newfiber.api.core.annotation.SysLog;
import com.newfiber.api.core.commons.ResultCode;
import com.newfiber.api.core.commons.ResultObj;
import com.newfiber.api.pc.model.gaofen.EmergencyCommandWeather;
import com.newfiber.api.pc.model.gaofen.OneByOneResponse;
import com.newfiber.api.pc.service.impl.GaofenWeatherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;

/**
 *  高分天气接口Api接口集成
 * @ClassName GaofenWeatherController
 * @Description TODO
 * @Author 张鸿志
 * @Date 2021年8月18日14:21:26 14:21
 * Version 1.0
 **/
@RestController
@RequestMapping("/geofenWeather")
@Api(value = "GaofenWeatherController",tags = "高分天气API接口集成")
public class GaofenWeatherController {

    @Autowired
    private GaofenWeatherService gaofenWeatherService;


    @PostMapping("/weatherForecast")
    @ApiOperation("应急指挥中获取一周天气预报接口")
    @SysLog(value = "应急指挥中获取一周天气预报接口",type = "4")
    public ResultObj<EmergencyCommandWeather>  weatherForecast(){
        EmergencyCommandWeather emergencyCommandWeather = gaofenWeatherService.getSmartAndDayByDayWeather();
        return new ResultObj<>(ResultCode.OK,emergencyCommandWeather);
    }


    @PostMapping("/getFutrueWeather")
    @ApiOperation("应急指挥中逐小时天气预报接口")
    @SysLog(value = "应急指挥中逐小时天气预报接口",type = "4")
    public ResultObj<OneByOneResponse> getFutrueWeather(@RequestParam("day") Integer day){
        return new ResultObj<>(ResultCode.OK,gaofenWeatherService.getFutrueWeather(day));
    }

    @PostMapping("/test")
    public ResultObj syncWeather(){
        try {
            gaofenWeatherService.getLastMonthWeather();
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return ResultObj.ok();
    }


}