package com.sptg.statistics.api.feigns.fallback;

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.common.core.beans.PageBean;
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.StatisticsAdClickMobileDto;
import com.sptg.statistics.api.dto.StatisticsAdPlayFreeTimeDto;
import com.sptg.statistics.api.dto.StatisticsAdWatchDto;
import com.sptg.statistics.api.entity.StatisticsAdClickMobile;
import com.sptg.statistics.api.entity.StatisticsAdPlayFreeTime;
import com.sptg.statistics.api.entity.StatisticsAdWatch;
import com.sptg.statistics.api.feigns.StatisticsAdWatchFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * title: VisitorFeignFallBackFactory
 * package: com.sptg.statistics.api.feigns.fallback
 * description: 广告观看统计容错处理
 *
 *                
 *                 
 */
@Component
@Slf4j
public class StatisticsAdWatchFeignFallBackFactory implements FallbackFactory<StatisticsAdWatchFeign> {
    @Override
    public StatisticsAdWatchFeign create(Throwable cause) {
        return new StatisticsAdWatchFeign() {
            @Override
            public ResultBean<Page<StatisticsAdWatch>> showStatisticsAdWatchList(StatisticsAdWatchDto statisticsAdWatchDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
            @Override
            public ResultBean<Boolean> addAdWatch(StatisticsAdWatch statisticsAdWatch) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
            @Override
            public ResultBean<Page<StatisticsAdWatch>> showStatisticsAdWatchRankList(StatisticsAdWatchDto statisticsAdWatchDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
            @Override
            public ResultBean<Map<String, Object>> statisticsAdWatchCount(StatisticsAdWatchDto statisticsAdWatchDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Long> statisticsAdWatchVisitorCount(StatisticsAdWatchDto statisticsAdWatchDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<List<Map<String, Object>>> statisticsAdWatchForChart(StatisticsAdWatchDto statisticsAdWatchDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public List<StatisticsAdWatch> getAdWatchList(StatisticsAdWatchDto statisticsAdWatchDto) {
                log.error(cause.getMessage(),cause);
                return new ArrayList<>(OperationConstant.ZERO);
            }

            @Override
            public List<StatisticsAdWatch> getAdWatchRankList(StatisticsAdWatchDto statisticsAdWatchDto) {
                log.error(cause.getMessage(),cause);
                return  new ArrayList<>(OperationConstant.ZERO);
            }

            @Override
            public List<Map<String, Object>> statisticsAdWatchRankForArea(StatisticsAdWatchDto statisticsAdWatchDto) {
                log.error(cause.getMessage(),cause);
                return new ArrayList<>(OperationConstant.ZERO);
            }

            @Override
            public Long getAdWatchCount(StatisticsAdWatchDto statisticsAdWatchDto) {
                log.error(cause.getMessage(),cause);
                return 0L;
            }

            @Override
            public List<Map<String, Object>> statisticsAdWatchCountChartByDateType(StatisticsAdWatchDto statisticsAdWatchDto) {
                log.error(cause.getMessage(),cause);
                return new ArrayList<>(OperationConstant.ZERO);
            }

            @Override
            public List<Map<String, Object>> statisticsAdWatchRankForAdType(StatisticsAdWatchDto statisticsAdWatchDto) {
                log.error(cause.getMessage(),cause);
                return new ArrayList<>(OperationConstant.ZERO);
            }

            @Override
            public List<Map<String, Object>> statisticsAdWatchPersonForDay(StatisticsAdWatchDto statisticsAdWatchDto) {
                log.error(cause.getMessage(),cause);
                return new ArrayList<>(OperationConstant.ZERO);
            }

            @Override
            public ResultBean<List<Map<String, Object>>> getAdWatchCountList(StatisticsAdWatchDto statisticsAdWatchDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Page<StatisticsAdPlayFreeTime>> showAdPlayFreeTimeRankList(PageBean<StatisticsAdPlayFreeTime, StatisticsAdPlayFreeTimeDto> pageBean) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Page<StatisticsAdClickMobile>> showAdClickMobileRankList(PageBean<StatisticsAdClickMobile, StatisticsAdClickMobileDto> pageBean) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> addAdClickMobile(StatisticsAdClickMobile statisticsAdClickMobile) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public Long getAdPlayCount(StatisticsAdPlayFreeTimeDto dto) {
                log.error(cause.getMessage(),cause);
                return null;
            }
        };
    }
}
