package com.goldenwater.slgc.controller.proxy;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.goldenwater.common.core.controller.BaseController;
import com.goldenwater.common.core.domain.AjaxResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;

@Tag(name = "27. 台风管理")
@RestController
@RequestMapping("/slgc/typhoon")
public class TyphoonController extends BaseController {

    private static final String API = "http://typhoon.zjwater.gov.cn/Api";

    @Operation(summary = "27.01 查询台风年份数据")
    @GetMapping("/year/list")
    public AjaxResult yearList() {
        return success(ProxyHelper.fetchJson(API + "/TyphoonList/0"));
    }

    @Operation(summary = "27.02 查询台风信息列表")
    @GetMapping("/info/list")
    public AjaxResult infoList(@RequestParam(defaultValue = "2024") String year) {
        return success(ProxyHelper.fetchJson(API + "/TyphoonList/" + year));
    }

    @Operation(summary = "27.03 查询台风路径数据")
    @GetMapping("/path/list")
    public AjaxResult pathList(String tfid) {
        return success(ProxyHelper.fetchJson(API + "/TyphoonInfo/" + (tfid != null ? tfid : "")));
    }

    @Operation(summary = "27.04 查询台风事件")
    @GetMapping("/event/list")
    public AjaxResult eventList(String tfid) {
        return success(ProxyHelper.fetchJson(API + "/TyphoonEvent/" + (tfid != null ? tfid : "") + "/Flase"));
    }

    @Operation(summary = "27.05 查询未来降雨")
    @GetMapping("/least/rain")
    public AjaxResult leastRain(@RequestParam(defaultValue = "24") String type) {
        return success(ProxyHelper.fetchJson(API + "/LeastRain/" + type));
    }

    @Operation(summary = "27.06 查询云图")
    @GetMapping("/least/cloud")
    public AjaxResult leastCloud() {
        return success(ProxyHelper.fetchJson(API + "/LeastCloud"));
    }
}
