package org.jeecg.modules.system.controller;

import cn.com.ctop.crawler.modules.account.entity.KuaishouAppAccount;
import cn.com.ctop.userefficientvideomap.entity.DesignMaterialInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.modules.system.service.IPerformanceService2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 设计师季度绩效表2
 *
 * @author jeecg-boot
 * @version V1.0
 * @date 2019-12-10
 */
@Slf4j
@Api(tags = "设计师季度绩效表2")
@RestController
@RequestMapping("/ctop/performance2")
public class PerformanceController2 {
    @Autowired
    private IPerformanceService2 performanceService;

    //平台的总有效数量、素材总数、素材有效率、总跑量、当前可获得绩效
    @AutoLog(value = "平台的总有效数量、素材总数、素材有效率、总跑量、当前可获得绩效")
    @ApiOperation(value = "平台的总有效数量、素材总数、素材有效率、总跑量、当前可获得绩效", notes = "平台的总有效数量、素材总数、素材有效率、总跑量、当前可获得绩效")
    @PostMapping(value = "/getPerformanceInfo")
    public Result<Map<String,Object>> getPerformanceInfo() {
        Result<Map<String,Object>> result = new Result<Map<String,Object>>();
        Map<String,Object> resultMap = new HashMap<>();
        try {
            resultMap = performanceService.getPerformanceInfo();
            result.setSuccess(true);
            result.setResult(resultMap);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            result.error500("/getPerformanceInfo出错啦");
        }
        return result;
    }

    //有效率排行榜
    @AutoLog(value = "有效率排行榜")
    @ApiOperation(value = "有效率排行榜", notes = "有效率排行榜")
    @PostMapping(value = "/effiRateRank")
    public Result<Map<String,Object>> effiRateRank(@RequestParam(name = "pageSize")Integer pageSize) {
        Result<Map<String,Object>> result = new Result<Map<String,Object>>();
        Map<String,Object> resultMap = new HashMap<>();
        try {
            resultMap = performanceService.effiRateRank(pageSize);
            result.setSuccess(true);
            result.setResult(resultMap);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            result.error500("/ctop/performance2/effiRateRank出错啦");
        }
        return result;
    }

    //素材、素材跑量、封面点击数、封面曝光数、行为数
    @AutoLog(value = "素材、素材跑量、封面点击数、封面曝光数、行为数")
    @ApiOperation(value = "素材、素材跑量、封面点击数、封面曝光数、行为数", notes = "素材、素材跑量、封面点击数、封面曝光数、行为数")
    @PostMapping(value = "/materialInfoList")
    public Result<Map<String,Object>> materialInfoList() {
        Result<Map<String,Object>> result = new Result<Map<String,Object>>();
        Map<String,Object> resultMap = new HashMap<>();
        try {
            List<DesignMaterialInfo> designMaterialInfoList= performanceService.materialInfoList();
            resultMap.put("designMaterialInfoList",designMaterialInfoList);
            result.setSuccess(true);
            result.setResult(resultMap);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            result.error500("/ctop/performance2/materialInfoList出错啦");
        }
        return result;
    }

    //点击+符号 投放账户、投放账户、跑量
    @AutoLog(value = "点击账户增加_投放账户、投放账户、跑量")
    @ApiOperation(value = "点击账户增加_投放账户、投放账户、跑量", notes = "点击账户增加_投放账户、投放账户、跑量")
    @PostMapping(value = "/materialAccountInfo")
    public Result<Map<String,Object>> materialAccountInfo(@RequestParam(name = "materialId")String materialId) {
        Result<Map<String,Object>> result = new Result<Map<String,Object>>();
        Map<String,Object> resultMap = new HashMap<>();
        try {
            List<DesignMaterialInfo> designMaterialInfoList= performanceService.materialAccountInfo(materialId);
            resultMap.put("designMaterialInfoList",designMaterialInfoList);
            result.setSuccess(true);
            result.setResult(resultMap);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            result.error500("/ctop/performance2/materialAccountInfo出错啦");
        }
        return result;
    }

}
