package cn.cecep.talroad.controller.analysis;

import cn.cecep.talroad.common.core.utils.poi.ExcelUtil;
import cn.cecep.talroad.common.core.web.controller.BasesController;
import cn.cecep.talroad.common.core.web.domain.AjaxResults;
import cn.cecep.talroad.common.log.annotation.Log;
import cn.cecep.talroad.common.log.enums.BusinessType;
import cn.cecep.talroad.domain.analysis.SRaOverRateWater;
import cn.cecep.talroad.service.analysis.ISRaOverRateWaterService;
import cn.cecep.talroad.vo.analysis.SRaOverRateWaterVo;
import cn.cecep.talroad.vo.query.analysis.SRaOverRateWaterQuery;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;


/**
 * * 开发公司：中节能天融科技有限公司
 * 超标率分析-水污染要素Controller 控制层
 *
 * @author szhpt
 * @date 2023-03-24
 */
@Api(tags = "超标率分析-水污染要素")
@RestController
@RequestMapping("/over/water")
public class SRaOverRateWaterController extends BasesController {
    @Autowired
    private ISRaOverRateWaterService sRaOverRateWaterService;

    /**
     * 查询超标率分析-水污染要素列表
     */
    @ApiOperation(value = "查询超标率分析-水污染要素")
    @GetMapping("/list")
    public AjaxResults<IPage<SRaOverRateWaterVo>> list(SRaOverRateWaterQuery query) {
        Page<SRaOverRateWaterVo> page = new Page<>(query.getPageNum(), query.getPageSize());
        sRaOverRateWaterService.selectOverRateWaterPage(page, query);
        return AjaxResults.success(page);
    }


    /**
     * 导出超标率分析-水污染要素列表
     */
    @ApiOperation(value = "导出超标率分析-水污染要素")
    @Log(title = "超标率分析-水污染要素", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, @RequestBody SRaOverRateWaterQuery query) {
        Page<SRaOverRateWaterVo> page = new Page<>(query.getPageNum(), query.getPageSize());
        List<SRaOverRateWaterVo> list = sRaOverRateWaterService.selectOverRateWaterPage(page, query);
        ExcelUtil<SRaOverRateWaterVo> util = new ExcelUtil<>(SRaOverRateWaterVo.class);
        util.exportExcel(response, list, "超标率分析-水污染要素数据");
    }

    /**
     * 获取超标率分析-水污染要素详细信息
     */
    @ApiOperation(value = "获取超标率分析-水污染要素详细信息")
    @PostMapping(value = "/{id}")
    public AjaxResults<SRaOverRateWater> getInfo(@PathVariable("id") Integer id) {
        return AjaxResults.success(sRaOverRateWaterService.getById(id));
    }

}
