package com.ytpm.controller.xjlrl;

import com.ytpm.app.param.DyzAdRecordParam;
import com.ytpm.general.Result;
import com.ytpm.middle.view.DashboardRankingListVO;
import com.ytpm.middle.view.DashboardRevenueVO;
import com.ytpm.service.qnjz.QnAdService;
import com.ytpm.service.xjlrl.XjlrlAdService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
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;
import java.math.BigDecimal;
import java.util.Map;

@Api(tags = "用户浏览广告记录")
@RestController
@RequestMapping("/xjl/ad")
public class XjlrlAdController {

    @Resource
    private XjlrlAdService xjladService;

    /**
     * 保存广告记录
     */
    @ApiOperation("保存")
    @PostMapping("/saveRecord")
    public Result<?> saveRecord(@RequestBody DyzAdRecordParam param){
        return xjladService.saveRecord(param);
    }

    /**
     * 根据应用ID查询广告数
     */
    @ApiOperation("根据应用ID查询广告数")
    @GetMapping("/getAdCount")
    public Map<String, BigDecimal> getAdCount(@RequestParam(name = "appIds")String appIds){
        return xjladService.getAdCount(appIds);
    }

    /**
     * 查询应用排行榜信息
     */
    @ApiImplicitParams({
            @ApiImplicitParam(name = "sortBy", value = "排行榜排序规则",required = true),
            @ApiImplicitParam(name = "limit", value = "排行榜显示数量",required = true),
    })
    @ApiOperation("查询应用排行榜信息")
    @GetMapping("/getAppRankingList")
    public DashboardRankingListVO queryRankingList(@RequestParam(name = "sortBy")Integer sortBy, @RequestParam(name = "limit")Integer limit){
        return xjladService.queryRankingList(sortBy,limit);
    }

    /**
     * 查询各渠道应用收益分时统计
     */
    @ApiImplicitParam(name = "apkIds", value = "渠道应用ID（,拼接）",required = true)
    @ApiOperation("查询各渠道应用收益分时统计")
    @GetMapping("/revenueStatics")
    public DashboardRevenueVO revenueStatics(@RequestParam(name = "apkIds")String apkIds){
        return xjladService.revenueStatics(apkIds);
    }
}
