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

import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.beans.ResultEnum;
import com.sptg.statistics.api.dto.StatisticsAdPushCountDto;
import com.sptg.statistics.api.entity.StatisticsAdPushCount;
import com.sptg.statistics.api.feigns.StatisticsAdPushCountFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * title: StatisticsFeignFallbackFactory
 * package: com.sptg.statistics.api.feigns.fallback
 * description: 统计广告发布数量-服务容错处理
 *
 *                
 *                
 */
@Component
@Slf4j
public class StatisticsAdPushCountFeignFallbackFactory implements FallbackFactory<StatisticsAdPushCountFeign> {

    @Override
    public StatisticsAdPushCountFeign create(Throwable cause) {
        return new StatisticsAdPushCountFeign(){

            @Override
            public StatisticsAdPushCount getStatisticsAdPushCountByTaskId(StatisticsAdPushCountDto statisticsAdPushCountDto) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public ResultBean<Boolean> addAdPushCount(StatisticsAdPushCountDto statisticsAdPushCountDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR,false);
            }

            @Override
            public ResultBean<Long> getAdPushCount(StatisticsAdPushCountDto statisticsAdPushCountDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR,0L);
            }

            @Override
            public ResultBean<Boolean> updateAdPushState(StatisticsAdPushCountDto statisticsAdPushCountDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR,false);
            }
        };
    }
}
