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

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.ad.api.dto.AdTypeDto;
import com.sptg.ad.api.entity.AdType;
import com.sptg.ad.api.feigns.AdTypeFeign;
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;

import java.util.List;

/**
 * title: AdTypeFeignFallbackFactory
 * package: com.sptg.ad.api.feigns.fallback
 * description: 广告类型接口容错处理
 *
 *               
 *                 
 */
@Slf4j
@Component
public class AdTypeFeignFallbackFactory implements FallbackFactory<AdTypeFeign> {
    @Override
    public AdTypeFeign create(Throwable cause) {
        return new AdTypeFeign() {
            @Override
            public ResultBean<Page<AdType>> showAdTypeList(AdTypeDto adTypeDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> addAdType(AdType adType) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

            @Override
            public ResultBean<AdType> getAdTypeList(Long rootOrgId) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> checkAdTypeName(AdType adType) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

            @Override
            public Integer getAdTypeCount(AdTypeDto adTypeDto) {
                log.error(cause.getMessage(),cause);
                return null;
            }
        };
    }
}
