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

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.ad.api.dto.AdPushDeviceDetailsDto;
import com.sptg.ad.api.entity.AdPushDeviceDetails;
import com.sptg.ad.api.feigns.AdPushDeviceDetailsFeign;
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: AdPushTaskFeignFallbackFactory
 * package: com.sptg.ad.api.feigns.fallback
 * description: 广告发布到设备详情接口容错处理
 *
 *               
 *                 
 */
@Slf4j
@Component
public class AdPushDeviceDetailsFallbackFactory implements FallbackFactory<AdPushDeviceDetailsFeign> {
    @Override
    public AdPushDeviceDetailsFeign create(Throwable cause) {
        return new AdPushDeviceDetailsFeign() {
            @Override
            public ResultBean<Page<AdPushDeviceDetails>> showAdPushDeviceDetails(AdPushDeviceDetailsDto adPushDeviceDetailsDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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