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.entity.StatisticsCount;
import com.sptg.statistics.api.feigns.StatisticsCountFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * title: StatisticsCountFeignFallBackFactory
 * package: com.sptg.statistics.api.feigns.fallback
 * description:统计数量-服务容错处理类
 *
 *                
 *                 
 */
@Component
@Slf4j
public class StatisticsCountFeignFallBackFactory  implements FallbackFactory<StatisticsCountFeign> {
    @Override
    public StatisticsCountFeign create(Throwable cause) {
        return new StatisticsCountFeign(){

            @Override
            public ResultBean<Boolean> addCount(StatisticsCount statisticsCount) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> addCountLcn(StatisticsCount statisticsCount) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<StatisticsCount> selectCountOne(String orgPosition) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
        };
    }
}
