package com.sptg.statistics.biz.controller;

import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.beans.ResultEnum;
import com.sptg.common.core.constant.OperationConstant;
import com.sptg.statistics.api.dto.StatisticsAdPushDto;
import com.sptg.statistics.api.entity.StatisticsAdPush;
import com.sptg.statistics.api.feigns.StatisticsAdPushFeign;
import com.sptg.statistics.biz.service.StatisticsAdPushServiceInterface;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

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

/**
 * title: StatisticsAdPushController
 * package: com.sptg.statistics.biz.controller
 * description: 广告发布统计-控制器
 *
 *                
 *                 
 */
@RestController
@AllArgsConstructor
public class StatisticsAdPushController implements StatisticsAdPushFeign {

    private final StatisticsAdPushServiceInterface statisticsAdPushServiceInterface;

    @PostMapping(value = "/statistics/statisticsAdPush/addAdPush")
    @Override
    public ResultBean<Boolean> addAdPush(@RequestBody StatisticsAdPush statisticsAdPush) {
        statisticsAdPushServiceInterface.addAdPush(statisticsAdPush);
        return new ResultBean<>(ResultEnum.SUCCESS,true);
    }

    @PostMapping(value = "/statistics/statisticsAdPush/addAdPushList")
    @Override
    public ResultBean<Boolean> addAdPushList(@RequestBody List<StatisticsAdPush> statisticsAdPushList) {
        statisticsAdPushServiceInterface.addAdPushList(statisticsAdPushList);
        return new ResultBean<>(ResultEnum.SUCCESS,true);
    }

    @PostMapping(value = "/statistics/statisticsAdPush/statisticsAdPushTotal")
    @Override
    public ResultBean<Map<String,Object>>  statisticsAdPushTotal(@RequestBody(required=false) StatisticsAdPushDto statisticsAdPushDto){
        Map<String,Object> resultMap= statisticsAdPushServiceInterface.statisticsAdPushTotal(statisticsAdPushDto);
        return  new ResultBean<>(ResultEnum.SUCCESS,resultMap);
    }

    @PostMapping(value = "/statistics/statisticsAdPush/statisticsCurrentMonthAdPushTotal")
    @Override
    public ResultBean<Map<String,Object>>  statisticsCurrentMonthAdPushTotal(@RequestBody StatisticsAdPushDto statisticsAdPushDto){
        Map<String,Object> resultMap= statisticsAdPushServiceInterface.statisticsCurrentMonthAdPushTotal(statisticsAdPushDto);
        return  new ResultBean<>(ResultEnum.SUCCESS,resultMap);
    }

    @PostMapping(value = "/statistics/statisticsAdPush/statisticsAdPushAndExposure")
    @Override
    public ResultBean<List<Map<String,Object>>>  statisticsAdPushAndExposure(@RequestBody StatisticsAdPushDto statisticsAdPushDto){
        List<Map<String,Object>> resultList=statisticsAdPushServiceInterface.statisticsAdPushAndExposure(statisticsAdPushDto);
        return  new ResultBean<List<Map<String,Object>>>(ResultEnum.SUCCESS,resultList);
    }

    @PostMapping(value = "/statistics/statisticsAdPush/statisticsAdPushAndExposureByArea")
    @Override
    public List<Map<String,Object>>  statisticsAdPushAndExposureByArea(@RequestBody StatisticsAdPushDto statisticsAdPushDto){
        List<Map<String,Object>> resultList=statisticsAdPushServiceInterface.statisticsAdPushAndExposureByArea(statisticsAdPushDto);
        return  resultList;
    }

    @PostMapping(value = "/statistics/statisticsAdPush/statisticsAdPushCount")
    @Override
    public Long  statisticsAdPushCount(@RequestBody StatisticsAdPushDto statisticsAdPushDto){
        long count=statisticsAdPushServiceInterface.statisticsAdPushCount(statisticsAdPushDto);
        return  count;
    }

    @Override
    @PostMapping(value = "/statistics/statisticsAdPush/getAdPushAccount")
    public ResultBean<Map<String, Long>> getAdPushAccount(@RequestBody StatisticsAdPushDto statisticsAdPushDto) {
        Map<String,Long> map = new HashMap<>(2);
        statisticsAdPushDto.setIsAllType(OperationConstant.ONE);
        long totalCount = this.statisticsAdPushServiceInterface.statisticsAdPushCount(statisticsAdPushDto);
        map.put("totalCount",totalCount);
        statisticsAdPushDto.setIsAllType(OperationConstant.TWO);
        long monthCount = this.statisticsAdPushServiceInterface.statisticsAdPushCount(statisticsAdPushDto);
        map.put("monthCount",monthCount);
        return new ResultBean<Map<String, Long>>(ResultEnum.SUCCESS,map);
    }
}
