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

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.ad.api.dto.AdAdsenseDto;
import com.sptg.ad.api.dto.AdContentDto;
import com.sptg.ad.api.entity.AdAdsense;
import com.sptg.ad.api.entity.AdContent;
import com.sptg.ad.api.feigns.AdAdsenseFeign;
import com.sptg.ad.api.feigns.AdContentFeign;
import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.beans.ResultEnum;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * title: AdAdsenseFeignFallbackFactory
 * package: com.sptg.ad.api.feigns.fallback
 * description: 广告位接口容错处理
 *
 *
 *
 */
@Slf4j
@Component
public class AdAdsenseFeignFallbackFactory implements FallbackFactory<AdAdsenseFeign> {

    @Override
    public AdAdsenseFeign create(Throwable cause) {
        return new AdAdsenseFeign() {
            @Override
            public ResultBean<Page<AdAdsense>> showAdAdsenseList(AdAdsenseDto adAdsenseDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> addAdAdsense(AdAdsense adAdsense) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> deleteAdAdsense(String ids) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public AdAdsense findAdsenseById(Long id) {
                log.error(cause.getMessage(),cause);
                return new AdAdsense();
            }

            @Override
            public ResultBean<Boolean> deleteAdsenseList(AdAdsenseDto adAdsenseDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> updateAdsenseStatus(Long id, String adsenseStatus) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
            @Override
            public ResultBean<Integer> getAllAdsenseCount() {
                return new ResultBean<>(ResultEnum.ERROR);
            }
        };
    }
}
