소스 검색

update 优化 oss远程接口增加扩展字段存储

疯狂的狮子Li 10 달 전
부모
커밋
7316d05874

+ 5 - 0
ruoyi-api/ruoyi-api-resource/src/main/java/org/dromara/resource/api/domain/RemoteFile.java

@@ -41,4 +41,9 @@ public class RemoteFile implements Serializable {
      */
     private String fileSuffix;
 
+    /**
+     * 扩展字段
+     */
+    private String ext1;
+
 }

+ 7 - 0
ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/dubbo/RemoteFileServiceImpl.java

@@ -7,11 +7,13 @@ import org.apache.dubbo.config.annotation.DubboService;
 import org.dromara.common.core.exception.ServiceException;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.StringUtils;
+import org.dromara.common.json.utils.JsonUtils;
 import org.dromara.common.oss.core.OssClient;
 import org.dromara.common.oss.entity.UploadResult;
 import org.dromara.common.oss.factory.OssFactory;
 import org.dromara.resource.api.RemoteFileService;
 import org.dromara.resource.api.domain.RemoteFile;
+import org.dromara.resource.domain.SysOssExt;
 import org.dromara.resource.domain.bo.SysOssBo;
 import org.dromara.resource.domain.vo.SysOssVo;
 import org.dromara.resource.service.ISysOssService;
@@ -50,6 +52,10 @@ public class RemoteFileServiceImpl implements RemoteFileService {
             oss.setFileName(uploadResult.getFilename());
             oss.setOriginalName(originalFilename);
             oss.setService(storage.getConfigKey());
+            SysOssExt ext1 = new SysOssExt();
+            ext1.setFileSize((long) file.length);
+            String extStr = JsonUtils.toJsonString(ext1);
+            oss.setExt1(extStr);
             sysOssService.insertByBo(oss);
             RemoteFile sysFile = new RemoteFile();
             sysFile.setOssId(oss.getOssId());
@@ -57,6 +63,7 @@ public class RemoteFileServiceImpl implements RemoteFileService {
             sysFile.setUrl(uploadResult.getUrl());
             sysFile.setOriginalName(originalFilename);
             sysFile.setFileSuffix(suffix);
+            sysFile.setExt1(extStr);
             return sysFile;
         } catch (Exception e) {
             log.error("上传文件失败", e);