package com.yunyan.web.controller.business;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yunyan.business.domain.FinalData;
import com.yunyan.business.pojo.admin.dto.FinalDataListDto;
import com.yunyan.business.pojo.admin.dto.StatisticsDto;
import com.yunyan.business.pojo.admin.vo.FinalDataListVo;
import com.yunyan.business.pojo.admin.vo.StatisticsVo;
import com.yunyan.business.service.IFinalDataService;
import com.yunyan.business.service.IStatisticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.yunyan.common.core.controller.BaseController;
import java.util.List;
import java.util.Optional;


/**
 * 数据统计Controller
 *
 * @author yunyan
 * @date 2023-08-16
 */
@Api(tags = "数据统计")
@RestController
@RequestMapping("/Statistics")
public class StatisticsController extends BaseController{

    @Autowired
    private IStatisticsService iStatisticsService;

    @Autowired
    private IFinalDataService finalDataService;

    /**
     * 查询数据统计接口
     * @param pageNum 当前页数
     * @param pageSize 显示条数
     * @param statisticsDto 查询入参（年份、区划名称、类型）
     * @return 返回统计结果集合
     */
    @GetMapping("/list")
    @ApiOperation(value="数据统计", notes="数据统计")
    public PageInfo<StatisticsVo> statisticsList(Integer pageNum, Integer pageSize, StatisticsDto statisticsDto) {
            PageHelper.startPage(Optional.ofNullable(pageNum).orElse(1),
                    Optional.ofNullable(pageSize).orElse(10));
            List<StatisticsVo> statistics = iStatisticsService.statisticsPage(statisticsDto);
            return new PageInfo<>(statistics);
    }

    /**
     * 查询数据明细接口
     * @param pageNum 当前页数
     * @param pageSize 显示条数
     * @param finalData 查询入参（必须）
     * @return 返回结果
     */
    @GetMapping("/list/detail")
    @ApiOperation(value = "明细接口",notes = "明细接口")
    public PageInfo<FinalDataListVo> list(FinalDataListDto dto){
        /*PageHelper.startPage(Optional.ofNullable(pageNum).orElse(1),
                Optional.ofNullable(pageSize).orElse(10));*/
        List<FinalDataListVo> list = finalDataService.selectFinalDataList(dto);
        return new PageInfo<>(list);
    }
}
