From 6aeeb1fbdea6b0f9c36678efd49bd90d2ca2a6dc Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Wed, 24 Apr 2024 15:41:25 +0800
Subject: [PATCH] 数据重复修改
---
skjcmanager/skjcmanager-ops/skjcmanager-resource/src/main/java/cn/gistack/resource/endpoint/OssEndpoint.java | 70 +++++++++++++++++++++++++++++++++++
1 files changed, 70 insertions(+), 0 deletions(-)
diff --git a/skjcmanager/skjcmanager-ops/skjcmanager-resource/src/main/java/cn/gistack/resource/endpoint/OssEndpoint.java b/skjcmanager/skjcmanager-ops/skjcmanager-resource/src/main/java/cn/gistack/resource/endpoint/OssEndpoint.java
index 5255973..c83c2a4 100644
--- a/skjcmanager/skjcmanager-ops/skjcmanager-resource/src/main/java/cn/gistack/resource/endpoint/OssEndpoint.java
+++ b/skjcmanager/skjcmanager-ops/skjcmanager-resource/src/main/java/cn/gistack/resource/endpoint/OssEndpoint.java
@@ -17,7 +17,9 @@
package cn.gistack.resource.endpoint;
import cn.gistack.resource.builder.oss.OssBuilder;
+import cn.gistack.resource.entity.TextualResearchAttach;
import cn.gistack.resource.service.IAttachService;
+import cn.gistack.resource.service.TextualResearchAttachService;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
@@ -32,6 +34,8 @@
import cn.gistack.resource.entity.Attach;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
+
+import java.util.*;
/**
* 对象存储端点
@@ -54,6 +58,11 @@
* 附件表服务
*/
private final IAttachService attachService;
+
+ /**
+ * 附件表服务
+ */
+ private final TextualResearchAttachService textualResearchAttachService;
/**
* 创建存储桶
@@ -149,6 +158,67 @@
}
/**
+ * 自定义前缀上传文件
+ *
+ * @param file 文件
+ * @param prefixPath 文件
+ * @return ObjectStat
+ */
+ @SneakyThrows
+ @PostMapping("/put-file-by-prefix-path")
+ public R<BladeFile> putFileByPrefixPath(@RequestParam MultipartFile file,@RequestParam String prefixPath) {
+ BladeFile bladeFile = ossBuilder.templateByPrefixPath(prefixPath).putFile(file.getOriginalFilename(), file.getInputStream());
+ return R.data(bladeFile);
+ }
+
+ /**
+ * 批量自定义前缀上传文件
+ *
+ * @param files 文件
+ * @param prefixPath 文件
+ * @return ObjectStat
+ */
+ @SneakyThrows
+ @PostMapping("/batch-put-file-by-prefix-path")
+ public R batchPutFileByPrefixPath(@RequestParam MultipartFile[] files,@RequestParam String prefixPath) {
+ List<BladeFile> list = new ArrayList<>();
+ for (MultipartFile file : files) {
+ BladeFile bladeFile = ossBuilder.templateByPrefixPath(prefixPath).putFile(file.getOriginalFilename(), file.getInputStream());
+ list.add(bladeFile);
+ }
+ return R.data(list);
+ }
+
+ /**
+ * 考证附件上传并保存
+ * @param file 文件
+ * @param resGuid 水库编号
+ * @return
+ */
+ @SneakyThrows
+ @PostMapping("/put-file-by-textualResearchAttach")
+ public R putFileByPrefixTextualResearchAttach(@RequestParam MultipartFile file,String resGuid,Integer type) {
+ BladeFile bladeFile = ossBuilder.templateByPrefixPath("textualResearchAttach").putFile(file.getOriginalFilename(), file.getInputStream());
+ buildTextualResearchAttach(resGuid,bladeFile,type);
+ return R.data(bladeFile);
+ }
+
+ /**
+ * 保存考证附件上传数据
+ * @param bladeFile
+ */
+ private void buildTextualResearchAttach(String resGuid,BladeFile bladeFile,Integer type) {
+ TextualResearchAttach attach = new TextualResearchAttach();
+ attach.setResGuid(resGuid);
+ attach.setType(type);
+ attach.setPath(bladeFile.getName());
+ attach.setName(bladeFile.getOriginalName());
+ attach.setCreateTime(new Date());
+ // 保存
+ textualResearchAttachService.save(attach);
+ }
+
+ /**
* 上传文件
*
* @param fileName 存储桶对象名称
--
Gitblit v1.9.3