|
@@ -0,0 +1,47 @@
|
|
|
+package com.usky.fire.factory;
|
|
|
+
|
|
|
+import com.usky.common.core.bean.ApiResult;
|
|
|
+import com.usky.common.core.exception.BusinessException;
|
|
|
+import com.usky.fire.RemoteUserService;
|
|
|
+import com.usky.fire.domain.SysUserVO;
|
|
|
+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 ruoyi
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class RemoteFireFallbackFactory implements FallbackFactory<RemoteUserService>
|
|
|
+{
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(RemoteFireFallbackFactory.class);
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public RemoteUserService create(Throwable throwable)
|
|
|
+ {
|
|
|
+ log.error("用户服务调用失败:{}", throwable.getMessage());
|
|
|
+ return new RemoteUserService() {
|
|
|
+ @Override
|
|
|
+ public ApiResult<List<SysUserVO>> getByUserName(String userName) {
|
|
|
+ throw new BusinessException(throwable.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ApiResult<List<SysUserVO>> add(SysUserVO sysUserVO) {
|
|
|
+ throw new BusinessException(throwable.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ApiResult<String> upload(MultipartFile file) {
|
|
|
+ throw new BusinessException(throwable.getMessage());
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }
|
|
|
+}
|