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

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.ad.api.dto.AdPushAppDto;
import com.sptg.ad.api.entity.AdPushApp;
import com.sptg.ad.api.feigns.AdPushAppFeign;
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;

/**
 * title: AdTypeFeignFallbackFactory
 * package: com.sptg.ad.api.feigns.fallback
 * description: 移动端广告接口容错处理
 *
 *               
 *                 
 */
@Slf4j
@Component
public class AdPushAppFeignFallbackFactory implements FallbackFactory<AdPushAppFeign> {
    @Override
    public AdPushAppFeign create(Throwable cause) {
        return new AdPushAppFeign() {

            @Override
            public ResultBean<Page<AdPushApp>> showList(AdPushAppDto dto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> addEntity(AdPushApp adPushApp) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> updateIsEnable(AdPushAppDto dto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

            @Override
            public ResultBean<AdPushApp> findById(Long id) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> editById(AdPushApp adPushApp) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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