From 1797c2a2455ce04f15678a5754d90908aa7d2e2c Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期二, 22 十月 2024 17:32:59 +0800
Subject: [PATCH] 2024-10-22 朱宝民 图片上传接口、音频上传接口、图片及音频路径获取接口
---
pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/get/GetFileCtrl.java | 72 ++++++++++++++++++++++++
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voFi/VoPhoto.java | 32 ++++++++++
pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/get/GetFileSv.java | 30 ++++++++++
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoFi/WebFileMapper.java | 1
4 files changed, 135 insertions(+), 0 deletions(-)
diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoFi/WebFileMapper.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoFi/WebFileMapper.java
index ef492f3..a2f3307 100644
--- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoFi/WebFileMapper.java
+++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoFi/WebFileMapper.java
@@ -18,4 +18,5 @@
int updateByPrimaryKey(WebFile record);
+
}
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voFi/VoPhoto.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voFi/VoPhoto.java
new file mode 100644
index 0000000..d1289ed
--- /dev/null
+++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voFi/VoPhoto.java
@@ -0,0 +1,32 @@
+package com.dy.pipIrrGlobal.voFi;
+
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import lombok.Data;
+
+/**
+ * @author ZhuBaoMin
+ * @date 2024-10-22 15:41
+ * @LastEditTime 2024-10-22 15:41
+ * @Description web鍥剧墖瑙嗗浘瀵硅薄
+ */
+
+@Data
+@JsonPropertyOrder({ "downloadPath", "webPath", "webPathZip"})
+public class VoPhoto {
+ private static final long serialVersionUID = 202410221542001L;
+
+ /**
+ * 鏂囦欢涓嬭浇璺緞
+ */
+ private String downloadPath;
+
+ /**
+ * web璺緞
+ */
+ private String webPath;
+
+ /**
+ * web璺緞锛堢缉鐣ュ浘锛�
+ */
+ private String webPathZip;
+}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/get/GetFileCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/get/GetFileCtrl.java
new file mode 100644
index 0000000..3518c3a
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/get/GetFileCtrl.java
@@ -0,0 +1,72 @@
+package com.dy.pipIrrWebFile.get;
+
+import com.dy.common.aop.SsoAop;
+import com.dy.common.webUtil.BaseResponse;
+import com.dy.common.webUtil.BaseResponseUtils;
+import com.dy.pipIrrGlobal.dyFile.FileOperate;
+import com.dy.pipIrrGlobal.dyFile.FileRestVo;
+import com.dy.pipIrrGlobal.pojoFi.WebFile;
+import com.dy.pipIrrGlobal.voFi.VoPhoto;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @author ZhuBaoMin
+ * @date 2024-10-22 15:26
+ * @LastEditTime 2024-10-22 15:26
+ * @Description 鑾峰彇鏂囦欢鎺у埗绫�
+ */
+
+@Slf4j
+@RestController
+@RequestMapping(path = "get")
+@RequiredArgsConstructor
+public class GetFileCtrl {
+ private final GetFileSv getFileSv;
+
+ @Autowired
+ private FileOperate fileOp ;
+
+ @Value("${dy.webFile.fmUrl}")
+ private String fmUrl ;
+
+ /**
+ * 鏍规嵁鍥剧墖ID鑾峰彇鍥剧墖璺緞
+ * @param photoId
+ * @return
+ */
+ @GetMapping(path = "/getPhotoFile")
+ @SsoAop()
+ public BaseResponse<VoPhoto> getPhotoFile(@RequestParam("photoId") Long photoId) {
+ try {
+
+ // 鏍规嵁鍥剧墖ID鑾峰彇鍥剧墖鏂囦欢瀵硅薄锛屼粠鍥剧墖鏂囦欢瀵硅薄涓幏鍙栨枃浠惰矾寰勩�佹墿灞曞悕銆佺缉鐣ュ浘鏂囦欢璺緞
+ WebFile webFile = getFileSv.getWebFileById(photoId);
+ if(webFile == null) {
+ return BaseResponseUtils.buildErrorMsg("鍥炬爣ID閿欒");
+ }
+ String filePath = webFile.getFilePath();
+ String extName = webFile.getExtName();
+ String filePathZip = filePath.substring(0, filePath.indexOf('.')) + "_." + extName;
+
+ FileRestVo frVo = fileOp.parseHashcode(fmUrl, webFile.hash);
+
+ VoPhoto photo = new VoPhoto();
+ photo.setDownloadPath(frVo.fileWebDownloadPath + photoId);
+ photo.setWebPath(frVo.fileWebUrl + filePath);
+ photo.setWebPathZip(frVo.fileWebUrl + filePathZip);
+
+ return BaseResponseUtils.buildSuccess(photo);
+ } catch (Exception e) {
+ log.error("鑾峰彇鍥剧墖鏂囦欢寮傚父", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/get/GetFileSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/get/GetFileSv.java
new file mode 100644
index 0000000..d0aea44
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/get/GetFileSv.java
@@ -0,0 +1,30 @@
+package com.dy.pipIrrWebFile.get;
+
+import com.dy.pipIrrGlobal.daoFi.WebFileMapper;
+import com.dy.pipIrrGlobal.pojoFi.WebFile;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author ZhuBaoMin
+ * @date 2024-10-22 15:27
+ * @LastEditTime 2024-10-22 15:27
+ * @Description
+ */
+
+@Slf4j
+@Service
+public class GetFileSv {
+ @Autowired
+ private WebFileMapper webFileMapper;
+
+ /**
+ * 鏍规嵁ID鑾峰彇鏂囦欢瀵硅薄
+ * @param fileId
+ * @return
+ */
+ public WebFile getWebFileById(Long fileId) {
+ return webFileMapper.selectByPrimaryKey(fileId);
+ }
+}
--
Gitblit v1.8.0