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 com.goldenwater.slgc.config.ApiProperties;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;

@Tag(name = "29. 水源地/水质/tba-gx代理")
@RestController
@RequestMapping("/slgc/tba-gx")
public class TbaGxController extends BaseController {

    private final ApiProperties apiProperties;

    public TbaGxController(ApiProperties apiProperties) {
        this.apiProperties = apiProperties;
    }

    @Operation(summary = "29.01 水源地水文最新数据")
    @GetMapping("/syq/newest")
    public AjaxResult syqNewest(@RequestParam(defaultValue = "n") String code) {
        return success(ProxyHelper.fetchJson(apiProperties.getTbaGx() + "/tba/gx/syq/newest?code=" + code));
    }

    @Operation(summary = "29.02 省界/流域水质最新数据")
    @GetMapping("/sj/basin/newest")
    public AjaxResult sjBasinNewest(@RequestParam String bizCode) {
        return success(ProxyHelper.fetchJson(apiProperties.getTbaGx() + "/tba/gx/sj/basin/newest?bizCode=" + bizCode));
    }

    @Operation(summary = "29.03 水质自动站最新数据")
    @GetMapping("/sz/auto/newest")
    public AjaxResult szAutoNewest(@RequestParam String bizCode) {
        return success(ProxyHelper.fetchJson(apiProperties.getTbaGx() + "/tba/gx/sz/auto/newest?bizCode=" + bizCode));
    }

    @Operation(summary = "29.04 蓝藻最新数据")
    @GetMapping("/sz/lz/newest")
    public AjaxResult szLzNewest(@RequestParam String bizCode) {
        return success(ProxyHelper.fetchJson(apiProperties.getTbaGx() + "/tba/gx/sz/lz/newest?bizCode=" + bizCode));
    }
}
