Explorar o código

update 优化 oss 远程调用 支持降级处理

疯狂的狮子Li %!s(int64=2) %!d(string=hai) anos
pai
achega
883fa32e2c

+ 37 - 0
ruoyi-api/ruoyi-api-resource/src/main/java/org/dromara/resource/api/RemoteFileServiceMock.java

@@ -0,0 +1,37 @@
+package org.dromara.resource.api;
+
+import lombok.extern.slf4j.Slf4j;
+import org.dromara.common.core.utils.StringUtils;
+import org.dromara.resource.api.domain.RemoteFile;
+
+/**
+ * 文件服务(降级处理)
+ *
+ * @author Lion Li
+ */
+@Slf4j
+public class RemoteFileServiceMock implements RemoteFileService {
+
+    /**
+     * 上传文件
+     *
+     * @param file 文件信息
+     * @return 结果
+     */
+    public RemoteFile upload(String name, String originalFilename, String contentType, byte[] file) {
+        log.warn("服务调用异常 -> 降级处理");
+        return null;
+    }
+
+    /**
+     * 通过ossId查询对应的url
+     *
+     * @param ossIds ossId串逗号分隔
+     * @return url串逗号分隔
+     */
+    public String selectUrlByIds(String ossIds) {
+        log.warn("服务调用异常 -> 降级处理");
+        return StringUtils.EMPTY;
+    }
+
+}

+ 1 - 1
ruoyi-common/ruoyi-common-translation/src/main/java/org/dromara/common/translation/core/impl/OssUrlTranslationImpl.java

@@ -16,7 +16,7 @@ import org.apache.dubbo.config.annotation.DubboReference;
 @TranslationType(type = TransConstant.OSS_ID_TO_URL)
 public class OssUrlTranslationImpl implements TranslationInterface<String> {
 
-    @DubboReference
+    @DubboReference(mock = "true")
     private RemoteFileService ossService;
 
     @Override