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

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.ad.api.dto.AdContentDto;
import com.sptg.ad.api.entity.AdContent;
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: AdContentFeignFallbackFactory
 * package: com.sptg.ad.api.feigns.fallback
 * description: 广告类容接口容错处理
 *
 *               
 *                 
 */
@Slf4j
@Component
public class AdContentFeignFallbackFactory implements FallbackFactory<AdContentFeign> {
    @Override
    public AdContentFeign create(Throwable cause) {
        return new AdContentFeign() {
            @Override
            public ResultBean<Page<AdContent>> showAdContentList(AdContentDto adContentDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> addAdContent(AdContent adContent) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

            @Override
            public ResultBean<Boolean> deleteAdContentList(AdContentDto adContentDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public AdContent findAdContentById(Long id) {
                log.error(cause.getMessage(),cause);
                return null;
            }

            @Override
            public ResultBean<AdContent> getList(AdContentDto dto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
        };
    }
}
