package com.op.system.api.factory;

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

import java.util.List;

/**
 * 用户服务降级处理
 *
 * @author OP
 */
@Component
public class RemoteMesFallbackFactory implements FallbackFactory<RemoteMesService> {
	private static final Logger log = LoggerFactory.getLogger(RemoteMesFallbackFactory.class);

	@Override
	public RemoteMesService create(Throwable throwable) {
		log.error("Mes服务调用失败:{}", throwable.getMessage());
		return new RemoteMesService() {
			@Override
			public R<Boolean> upLoadFile(List<BaseFileData> files) {
				return R.fail("上传失败:" + throwable.getMessage());
			}
		};
	}
}

