package com.weather.controller;


import com.weather.common.AjaxResult;
import com.weather.common.BaseController;
import com.weather.common.page.TableDataInfo;
import com.weather.entity.WeaAuditRotaInfo;
import com.weather.service.IWeaAuditRotaInfoService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * <p>
 * 审核信息 前端控制器
 * </p>
 *
 * @author feng
 * @since 2023-09-05
 */
@RestController
@RequestMapping("weaAuditRotaInfo")
public class WeaAuditRotaInfoController extends BaseController {

    @Autowired
    private IWeaAuditRotaInfoService weaAuditRotaInfoService;

    /**
     * 获取审核信息列表
     */
    @ApiOperation(value = "获取审核信息列表")
    @GetMapping("/list")
    public TableDataInfo list(WeaAuditRotaInfo weaAuditRotaInfo)
    {
        startPage();
        List<WeaAuditRotaInfo> list = weaAuditRotaInfoService.selectWeaAuditRotaInfoList(weaAuditRotaInfo);
        return getDataTable(list);
    }

    /**
     * 根据审核信息编号获取详细信息
     */
    @ApiOperation(value = "根据编号获取详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable Long id)
    {
        return success(weaAuditRotaInfoService.selectWeaAuditRotaInfoById(id));
    }


    /**
     * 根据年份获取详细信息
     */
    @ApiOperation(value = "根据年份获取详细信息")
    @GetMapping(value = "/yearList/{rotaYear}")
    public AjaxResult getYearInfo(@PathVariable String rotaYear)
    {

        if (rotaYear==null || rotaYear =="")
        {
            return error("查询年份不能为空");
        }
        List<WeaAuditRotaInfo> list = weaAuditRotaInfoService.selectWeaAuditRotaInfoByDate(rotaYear);

        return success(list);
    }

    /**
     * 新增审核信息
     */

    @ApiOperation(value = "新增审核信息")
    @PostMapping
    public AjaxResult add(@Validated @RequestBody WeaAuditRotaInfo weaAuditRotaInfo)
    {

        return toAjax(weaAuditRotaInfoService.insertWeaAuditRotaInfo(weaAuditRotaInfo));
    }

    /**
     * 修改审核信息
     */

    @ApiOperation(value = "修改审核信息")
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody WeaAuditRotaInfo weaAuditRotaInfo)
    {

        return toAjax(weaAuditRotaInfoService.updateWeaAuditRotaInfo(weaAuditRotaInfo));
    }

    /**
     * 删除审核信息
     */

    @ApiOperation(value = "删除审核信息")
    @DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable Long id)
    {
        return toAjax(weaAuditRotaInfoService.deleteWeaAuditRotaInfoById(id));
    }

}

