package com.reyun.saas.web.controller.report;

import com.reyun.saas.common.framework.ApiRestController;
import com.reyun.saas.common.restResult.RestResult;
import com.reyun.saas.report.data.service.DataService;
import com.reyun.saas.report.vo.ReportParamsVO;
import com.reyun.saas.security.utils.SecurityUtils;
import com.reyun.saas.web.aop.ReportDateProcess;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @desc
 * @date
 */
@ApiRestController("report")
@Api(value = "/report", tags = "报表数据接口")
public class ReportController {

    @Autowired
    private DataService dataServiceImpl;


    @ApiOperation(value = "数据看板->环比数据", notes = "" , produces = "application/json")
    @ReportDateProcess
    @PostMapping("dashboard/relative")
    public RestResult relative(@RequestBody ReportParamsVO reportParamsVO){
        return dataServiceImpl.relative(reportParamsVO);
    }

    @ApiOperation(value = "数据看板->图表数据", notes = "" , produces = "application/json")
    @ReportDateProcess
    @PostMapping("dashboard/chart")
    public RestResult dashboardChart(@RequestBody ReportParamsVO reportParamsVO){
        return dataServiceImpl.dashboardChart(reportParamsVO);
    }

    @ApiOperation(value = "渠道质量排行->图表数据", notes = "" , produces = "application/json")
    @ReportDateProcess
    @PostMapping("channelQualityTop/chart")
    public RestResult channelQualityTopChart(@RequestBody ReportParamsVO reportParamsVO,@ApiParam(name="type",value = "按数量：num,按比例：rate(不传默认为num)") @RequestParam(name = "type",required = false,defaultValue = "num") String type){
        return dataServiceImpl.channelQualityTopChart(reportParamsVO,type);
    }

    @ApiOperation(value = "渠道质量排行->Table数据", notes = "" , produces = "application/json")
    @ReportDateProcess
    @PostMapping("channelQualityTop/list")
    public RestResult channelQualityTopList(@RequestBody ReportParamsVO reportParamsVO){
        return dataServiceImpl.channelQualityTopList(reportParamsVO);
    }

    @ApiOperation(value = "统计分析->图表数据", notes = "" , produces = "application/json")
    @ReportDateProcess
    @PostMapping("statisticAnalysis/chart")
    public RestResult statisticAnalysisChart(@RequestBody ReportParamsVO reportParamsVO){
        return dataServiceImpl.statisticAnalysisChart(reportParamsVO, SecurityUtils.getLoginUserId());
    }

    @ApiOperation(value = "统计分析->Table数据", notes = "" , produces = "application/json")
    @ReportDateProcess
    @PostMapping("statisticAnalysis/list")
    public RestResult statisticAnalysisList(@RequestBody ReportParamsVO reportParamsVO){
        return dataServiceImpl.statisticAnalysisList(reportParamsVO,SecurityUtils.getLoginUserId());
    }

}
