From ed4a5236bab800094be4a8378f5098eebe3de6ac Mon Sep 17 00:00:00 2001
From: yangys <y_ys79@sina.com>
Date: 星期四, 04 四月 2024 23:30:30 +0800
Subject: [PATCH] 清楚不不要的mapstruct文件
---
smart-man-boot/src/main/java/com/qianwen/smartman/modules/resource/endpoint/OssEndpointController.java | 82 ++++++++++++++++++++++-------------------
1 files changed, 44 insertions(+), 38 deletions(-)
diff --git a/smart-man-boot/src/main/java/com/qianwen/smartman/modules/resource/endpoint/OssEndpointController.java b/smart-man-boot/src/main/java/com/qianwen/smartman/modules/resource/endpoint/OssEndpointController.java
index 9db0b37..aa45389 100644
--- a/smart-man-boot/src/main/java/com/qianwen/smartman/modules/resource/endpoint/OssEndpointController.java
+++ b/smart-man-boot/src/main/java/com/qianwen/smartman/modules/resource/endpoint/OssEndpointController.java
@@ -4,6 +4,8 @@
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.IoUtil;
import io.swagger.annotations.Api;
+import me.zhyd.oauth.log.Log;
+
import java.io.IOException;
import java.io.InputStream;
import javax.servlet.http.HttpServletResponse;
@@ -75,35 +77,21 @@
@GetResource({"/file-content"})
public void getFileContent(@RequestParam String fileName, HttpServletResponse response) {
- InputStream objectStream;
- Throwable th;
- try {
- objectStream = this.ossBuilder.template().getObject(fileName);
- th = null;
- } catch (IOException e) {
- e.printStackTrace();
- } catch (Exception e2) {
- throw new ServiceException("鏂囦欢涓嶅瓨鍦�");
- }
- try {
+
+ try (InputStream objectStream = this.ossBuilder.template().getObject(fileName)) {
response.setContentType("application/octet-stream; charset=UTF-8");
response.addHeader("Expires", "0");
response.addHeader("Pragma", "no-cache");
response.addHeader("Cache-Control", "no-cache, no-store, must-revalidate");
IoUtil.copy(objectStream, response.getOutputStream());
- if (objectStream != null) {
- if (0 != 0) {
- try {
- objectStream.close();
- } catch (Throwable th2) {
- th.addSuppressed(th2);
- }
- } else {
- objectStream.close();
- }
- }
- } finally {
- }
+
+ } catch (IOException e) {
+ Log.error("鑾峰彇鏂囦欢鍐呭閿欒",e);
+ e.printStackTrace();
+ } catch (Exception e) {
+ throw new ServiceException("鏂囦欢涓嶅瓨鍦�");
+ }
+
}
@PostResource({"/put-file"})
@@ -128,19 +116,31 @@
@PostResource({"/put-file-attach"})
public R<BladeFile> putFileAttach(@RequestParam MultipartFile file) {
- String fileName = file.getOriginalFilename();
- BladeFile bladeFile = this.ossBuilder.template().putFile(fileName, file.getInputStream());
- Long attachId = buildAttach(fileName, Long.valueOf(file.getSize()), bladeFile);
- bladeFile.setAttachId(attachId);
- return R.data(bladeFile);
+ try {
+ String fileName = file.getOriginalFilename();
+ BladeFile bladeFile = this.ossBuilder.template().putFile(fileName, file.getInputStream());
+ Long attachId = buildAttach(fileName, Long.valueOf(file.getSize()), bladeFile);
+ bladeFile.setAttachId(attachId);
+ return R.data(bladeFile);
+ } catch (Throwable ex) {
+ //log.error("putFileAttachByName,寮傚父,file={}",fileName,ex);
+ throw new ServiceException("putFileAttach寮傚父"+ex.getMessage());
+
+ }
}
@PostResource({"/put-file-attach-by-name"})
public R<BladeFile> putFileAttachByName(@RequestParam String fileName, @RequestParam MultipartFile file) {
- BladeFile bladeFile = this.ossBuilder.template().putFile(fileName, file.getInputStream());
- Long attachId = buildAttach(fileName, Long.valueOf(file.getSize()), bladeFile);
- bladeFile.setAttachId(attachId);
- return R.data(bladeFile);
+ try {
+ BladeFile bladeFile = this.ossBuilder.template().putFile(fileName, file.getInputStream());
+ Long attachId = buildAttach(fileName, Long.valueOf(file.getSize()), bladeFile);
+ bladeFile.setAttachId(attachId);
+ return R.data(bladeFile);
+ } catch (Throwable ex) {
+ //log.error("putFileAttachByName,寮傚父,file={}",fileName,ex);
+ throw new ServiceException("putFileAttachByName寮傚父"+ex.getMessage());
+
+ }
}
private Long buildAttach(String fileName, Long fileSize, BladeFile bladeFile) {
@@ -170,10 +170,16 @@
@PostResource({"/get-file-detail"})
public R<BladeFile> getFileDetail(@RequestParam MultipartFile file) {
- BladeFile bladeFile = this.ossBuilder.template().putFile(file.getName(), file.getInputStream());
- long size = file.getSize();
- Long attachId = buildAttach(file.getName(), Long.valueOf(size), bladeFile);
- bladeFile.setAttachId(attachId);
- return R.data(bladeFile);
+ try {
+ BladeFile bladeFile = this.ossBuilder.template().putFile(file.getName(), file.getInputStream());
+ long size = file.getSize();
+ Long attachId = buildAttach(file.getName(), Long.valueOf(size), bladeFile);
+ bladeFile.setAttachId(attachId);
+ return R.data(bladeFile);
+ } catch (Throwable ex) {
+ //log.error("putFileAttachByName,寮傚父,file={}",fileName,ex);
+ throw new ServiceException("getFileDetail寮傚父"+ex.getMessage());
+
+ }
}
}
--
Gitblit v1.9.3