package cn.iocoder.yudao.module.product.controller.admin.statistics;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.product.controller.admin.envdata.vo.EnvDataRespVO;
import cn.iocoder.yudao.module.product.controller.admin.statistics.vo.HarvestInfoDataRespVO;
import cn.iocoder.yudao.module.product.controller.admin.statistics.vo.TopDataRespVO;
import cn.iocoder.yudao.module.product.service.statistics.StatisticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "管理后台 - 生产数据统计")
@RestController
@RequestMapping("/product/statistics")
@Validated
public class StatisticsController {

    @Resource
    private StatisticsService statisticsService;

    @GetMapping("/topData")
    @ApiOperation("获得首页顶部的数据统计")
    @PreAuthorize("@ss.hasPermission('product:land-info:query')")
    public CommonResult<TopDataRespVO> getTopDataStatistics() {
        return CommonResult.success(statisticsService.getTopDataStatistics());
    }

    @GetMapping("/harvestInfoData")
    @ApiOperation("获得首页采收入库的数据统计")
    @PreAuthorize("@ss.hasPermission('product:land-info:query')")
    public CommonResult<HarvestInfoDataRespVO> getHarvestInfoDataStatistics() {
        return CommonResult.success(statisticsService.getHarvestInfoDataStatistics());
    }

    @GetMapping("/avgEnvData")
    @ApiOperation("获得首页环境数据统计")
    @PreAuthorize("@ss.hasPermission('product:land-info:query')")
    public CommonResult<List<EnvDataRespVO>> getAvgEnvDataStatistics() {
        return CommonResult.success(statisticsService.getAvgEnvDataStatistics());
    }

}
