package com.siwei.system.api.factory;

import com.siwei.common.core.domain.R;
import com.siwei.system.api.RemoteAuditflowTypeService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 核查服务降级处理
 *
 * @author siwei-zhx
 */
@Component
public class RemoteAuditflowTypeFallbackFactory implements FallbackFactory<RemoteAuditflowTypeService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteAuditflowTypeFallbackFactory.class);

    @Override
    public RemoteAuditflowTypeService create(Throwable throwable) {
        log.error("核查服务调用失败:{}", throwable.getMessage());
        return new RemoteAuditflowTypeService() {
            @Override
            public R<Boolean> auditFlowCache(String source) {
                return R.fail("核查流程緩存失败:" + throwable.getMessage());
            }
        };
    }
}
