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

import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.beans.ResultEnum;
import com.sptg.device.api.entity.InstructPublishLogDustbin;
import com.sptg.device.api.feigns.InstructPublishLogDustbinFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author zwx
 * @create 2020/7/26 16:22
 */
@Component
@Slf4j
public class InstructPublishLogDustbinFeignFallbackFactory implements FallbackFactory<InstructPublishLogDustbinFeign> {
    @Override
    public InstructPublishLogDustbinFeign create(Throwable cause) {
        return new InstructPublishLogDustbinFeign() {


            @Override
            public ResultBean<Boolean> insertLogDustbin(InstructPublishLogDustbin instructPublishLogDustbin) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> insertLogDustbinList(List<InstructPublishLogDustbin> logDustbins) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }
        };
    }
}
