package com.vctgo.system.api.factory;

import com.vctgo.common.core.domain.R;
import com.vctgo.system.api.RemoteFileService;
import com.vctgo.system.api.RemoteMessageService;
import com.vctgo.system.api.domain.FileInfo;
import com.vctgo.system.api.domain.MessageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * 文件服务降级处理
 *
 * @author vctgo
 */
@Component
public class RemoteMessageFallbackFactory implements FallbackFactory<RemoteMessageService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteMessageFallbackFactory.class);

    @Override
    public RemoteMessageService create(Throwable throwable) {
        log.error("消息服务调用失败:{}", throwable.getMessage());
        return new RemoteMessageService() {
            @Override
            public R addByTenantId(MessageInfo messageInfo) {
                return R.fail("临时忽略消息表，通过非租户内部来给租户推送消息失败:" + throwable.getMessage());
            }

            @Override
            public R batchAddByTenantId(String messageInfo) {
                return R.fail("临时忽略消息表，批量通过非租户内部来给租户推送消息失败:" + throwable.getMessage());
            }
        };
    }
}
