package com.rehome.jpahefengweather.controller;

import com.rehome.jpahefengweather.dto.TyphoonBaseDto;
import com.rehome.jpahefengweather.dto.WztfStormInfoDto;
import com.rehome.jpahefengweather.entity.*;
import com.rehome.jpahefengweather.service.WztfStormService;
import com.rehome.jpahefengweather.utils.Result;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/typhoon")
public class WztfwStormController {

    @Resource
    private WztfStormService wztfStormService;


    //endregion
    //region 根据年份获取台风列表
    @PostMapping("/getWztfStormListByYear")
//    @ApiOperation(value = "获取台风列表", notes = "获取台风列表")
//    @ApiImplicitParams(value = {
//            @ApiImplicitParam(name = "dto", value = "获取台风列表", dataTypeClass = TyphoonBaseDto.class, paramType = "body", required = true),
//    })
    public Result<List<WztfStorm>> getWztfStormListByYear(@Validated @RequestBody TyphoonBaseDto dto){
        return Result.of(this.wztfStormService.findByYear(dto.getYear()));
    }
    //endregion

    //region 根据台风id获取单条台风数据
    @PostMapping("/getWztfStormInfoByTfbh")
//    @ApiOperation(value = "根据台风id获取单条台风数据", notes = "根据台风id获取单条台风数据")
//    @ApiImplicitParams(value = {
//            @ApiImplicitParam(name = "dto", value = "根据台风id获取单条台风数据", dataTypeClass = WztfStormInfoDto.class, paramType = "body", required = true),
//    })
    public Result<WztfStormInfo> getWztfStormInfoByTfbh(@Validated @RequestBody WztfStormInfoDto dto){
        return Result.of(this.wztfStormService.findWztfStormInfoByTfbh(dto.getTfbh()));
    }
    //endregion

}
