package com.ytpm.middle.controller;

import com.ytpm.general.Result;
import com.ytpm.middle.service.CountService;
import com.ytpm.middle.view.DashboardRankingListVO;
import com.ytpm.middle.view.DashboardRevenueVO;
import com.ytpm.middle.view.DashboardRiskVO;
import com.ytpm.middle.view.DashboardTopCountVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api(tags = "首页模块")
@RestController
@RequestMapping("/dashboard")
public class HomeController {

    @Resource
    private CountService countService;

    @ApiOperation("获取顶部数据统计")
    @GetMapping("/topCount")
    public Result<DashboardTopCountVo> getTopCount() {
        return countService.getTopCount();
    }

    @ApiImplicitParam(name = "sortBy", value = "排序规则 1-当日 2-每周")
    @ApiOperation("排行榜信息")
    @GetMapping("/rankingList")
    public Result<DashboardRankingListVO> getRankingList(@RequestParam(name = "sortBy")Integer sortBy) {
        return countService.getRankingList(sortBy);
    }

    @ApiImplicitParam(name="appId", value = "所属应用ID")
    @ApiOperation(value = "根据应用ID获取各渠道收益统计数据")
    @GetMapping("/revenueStatics")
    public Result<DashboardRevenueVO> getRevenueStatics(@RequestParam(name = "appId")String appId) {
        return countService.getRevenueStatics(appId);
    }

    @ApiImplicitParam(name="appId", value = "所属应用ID")
    @ApiOperation(value = "根据应用ID获取用户风控数据")
    @GetMapping("/userStatics")
    public Result<DashboardRiskVO> getUserStatics(@RequestParam(name = "appId")String appId) {
        return countService.getUserStatics(appId);
    }


}
