From 8b7ce95e1f486603247f5cae882c4595e351af21 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期二, 23 四月 2024 17:04:56 +0800
Subject: [PATCH] 分布式web文件子系统增加下载web文件功能
---
pms-parent/pms-web-file/src/main/java/com/dy/dyFile/files/FileCtrl.java | 3
pms-parent/pms-web-file/src/main/java/com/dy/dyFile/download/DownloadFileSv.java | 32 +++++
pms-parent/pms-web-file/src/main/java/com/dy/dyFile/download/DownloadFileCtrl.java | 108 ++++++++++++++++++
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/dyFile/FileVo.java | 5
pms-parent/pms-global/src/main/resources/application-global.yml | 24 ++--
pms-parent/pms-global/src/main/resources/mapper/OthFileMapper.xml | 32 ++++
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoOth/OthFile.java | 59 +++++++--
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/global/WebFileCtrl.java | 28 ++--
/dev/null | 18 ---
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/dyFile/FileOperate.java | 8
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/dyFile/FileRestVo.java | 8
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoOth/OthFileMapper.java | 6
pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/dyFm/DyFileSvConf.java | 6
13 files changed, 255 insertions(+), 82 deletions(-)
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoOth/OthFileMapper.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoOth/OthFileMapper.java
index 3fbe311..156d80d 100644
--- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoOth/OthFileMapper.java
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoOth/OthFileMapper.java
@@ -5,15 +5,15 @@
@Mapper
public interface OthFileMapper {
- OthFile selectByPrimaryKey(Long id);
+ int deleteByPrimaryKey(Long id);
int insert(OthFile record);
int insertSelective(OthFile record);
+ OthFile selectByPrimaryKey(Long id);
+
int updateByPrimaryKeySelective(OthFile record);
int updateByPrimaryKey(OthFile record);
-
- int deleteByPrimaryKey(Long id);
}
\ No newline at end of file
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/dyFile/FileOperate.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/dyFile/FileOperate.java
index c9774c6..bde0f4e 100644
--- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/dyFile/FileOperate.java
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/dyFile/FileOperate.java
@@ -124,10 +124,10 @@
rvo = this.restCreateFileName(fmUrl, fileExtName) ;
if(rvo != null){
String relativeFilePath = this.restSaveFile(fileCtrlRqMp, fileMethodMp, file, regionNum, json, rvo);
- //log.info("瀛樺偍鏂囦欢鐢熸垚鏂囦欢璺緞锛�" + relativeFilePath);
- if(relativeFilePath != null){
- rvo.createFilePath(relativeFilePath, rvo.fileNameHash);
- }
+ rvo.fileWebPath = relativeFilePath ;
+ //if(relativeFilePath != null){
+ // rvo.createFilePath(relativeFilePath, rvo.fileNameHash);
+ //}
}
}
return rvo ;
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/dyFile/FileRestVo.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/dyFile/FileRestVo.java
index f25b474..88f3ba9 100644
--- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/dyFile/FileRestVo.java
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/dyFile/FileRestVo.java
@@ -12,8 +12,8 @@
public String fileSysAbsolutePath; //鏂囦欢鍚嶇О鐨勫搱甯屽�煎搴旂殑鏂囦欢鏈�缁堝瓨鍌ㄧ粷瀵硅矾寰勪腑鐨勬牴鐩綍锛屽湪閰嶇疆鏂囦欢涓厤缃�
public String fileSysRelativePath; //鏂囦欢鍚嶇О鐨勫搱甯屽�煎搴旂殑鏂囦欢鏈�缁堝瓨鍌ㄧ浉瀵硅矾寰勭殑鐩綍锛屽湪閰嶇疆鏂囦欢涓厤缃�
public String fileSysRestUrl; //鏂囦欢鍚嶇О鐨勫搱甯屽�煎搴旂殑鏂囦欢绯荤粺鐨剅estful URL锛屽湪閰嶇疆鏂囦欢涓厤缃�
- public String fileWebPath; //鏂囦欢鍚嶇О鐨勫搱甯屽�煎搴旂殑鏂囦欢绯荤粺鐨勪笅杞芥枃浠剁殑web path锛屽姩鎬佺敓鎴�
- public String fileWebUrl; //鏂囦欢鍚嶇О鐨勫搱甯屽�煎搴旂殑鏂囦欢绯荤粺鐨勪笅杞芥枃浠剁殑web URL锛屽湪閰嶇疆鏂囦欢涓厤缃�
+ public String fileWebPath; //鏂囦欢鍚嶇О鐨勫搱甯屽�煎搴旂殑鏂囦欢绯荤粺鐨勬樉绀哄強涓嬭浇鏂囦欢鐨剋eb path锛屽姩鎬佺敓鎴�
+ public String fileWebUrl; //鏂囦欢鍚嶇О鐨勫搱甯屽�煎搴旂殑鏂囦欢绯荤粺鐨勬樉绀烘枃浠剁殑web URL锛屽湪閰嶇疆鏂囦欢涓厤缃�
public String fileWebDownloadUrl; //鏂囦欢鍚嶇О鐨勫搱甯屽�煎搴旂殑鏂囦欢绯荤粺鐨凙ction涓嬭浇鏂囦欢鐨剋eb URL锛屽湪閰嶇疆鏂囦欢涓厤缃�
public String toString(){
@@ -29,10 +29,10 @@
}
/**
+ * 姝ゆ柟娉曚笉鐢ㄤ簡锛屽洜涓烘枃浠跺悕绉板悗闈㈠姞涓� 锛焗ashcode鍚庯紝涓嬭浇鏂囦欢绫讳腑灏嗘壘鍒颁笉鏂囦欢
* 閲嶆柊鍒涘缓fileSysWebUrl
* @param relativeFilePath
* @param hashcode
- */
public void createFilePath(String relativeFilePath, Integer hashcode){
if(relativeFilePath != null){
if(relativeFilePath.indexOf("?") < 0){
@@ -40,5 +40,5 @@
}
}
}
-
+ */
}
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/dyFile/FileVo.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/dyFile/FileVo.java
index 45fcf4d..299eff3 100644
--- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/dyFile/FileVo.java
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/dyFile/FileVo.java
@@ -10,6 +10,7 @@
public String extName ;//鏂囦欢鎵╁睍鍚�
public String webPath ;//web鏂囦欢璁块棶璺緞
public String webPathZip;//鐓х墖鏂囦欢缂╃暐鍥捐闂矾寰勶紝鍏朵粬绫诲瀷鏂囦欢姝ゅ睘鎬т负null
+ public String downloadPath;//web鏂囦欢涓嬭浇璺緞锛屽簲鐢ㄦ椂璺緞鍚庨潰鍔犱笂 ?id=[id]
public FileVo(){}
@@ -18,12 +19,14 @@
String orgName,
String extName,
String webPath,
- String webPathZip){
+ String webPathZip,
+ String downloadPath){
this.id = id ;
this.hash = hash ;
this.orgName = orgName ;
this.extName = extName ;
this.webPath = webPath ;
this.webPathZip = webPathZip ;
+ this.downloadPath = downloadPath ;
}
}
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/global/WebFileCtrl.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/global/WebFileCtrl.java
index 7472b24..97470ab 100644
--- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/global/WebFileCtrl.java
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/global/WebFileCtrl.java
@@ -9,7 +9,6 @@
import com.dy.pmsGlobal.dyFile.FileRestVo;
import com.dy.pmsGlobal.dyFile.FileVo;
import com.dy.pmsGlobal.pojoOth.OthFile;
-import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -39,7 +38,7 @@
@PostMapping("/upPhoto")
@SsoPowerAop(power = "-1") //鐧诲綍涓庢潈闄愬悓鏃堕獙璇�
//https://blog.zhengru.top/posts/33486.html#%E5%8D%95%E6%96%87%E4%BB%B6%E4%B8%8A%E4%BC%A0
- public BaseResponse<?> upPhoto(MultipartFile file, HttpServletRequest req) {
+ public BaseResponse<?> upPhoto(MultipartFile file) {
try {
if (file != null) {
String[] fileNameGrp = fileOp.splitFileName(file) ;
@@ -53,8 +52,8 @@
fileNameGrp[1],
null);
String fileMainName = fileOp.getFileMainName(frVo.fileName) ;
- Long id = this.saveFileInfo(fileNameGrp[0], fileNameGrp[1], fileMainName, frVo.fileNameHash, frVo.fileWebPath);
- FileVo fvo = new FileVo(id, frVo.fileNameHash, fileNameGrp[0], fileNameGrp[1], (frVo.getFileWebUrl() + frVo.getFileWebPath()), fileOp.getImgFileZipPath(frVo.getFileWebUrl() + frVo.getFileWebPath())) ;
+ Long id = this.saveFileInfo(fileNameGrp[0], fileNameGrp[1], fileMainName, frVo.fileNameHash, frVo.fileWebPath, frVo.fileWebDownloadUrl);
+ FileVo fvo = new FileVo(id, frVo.fileNameHash, fileNameGrp[0], fileNameGrp[1], (frVo.getFileWebUrl() + frVo.getFileWebPath()), fileOp.getImgFileZipPath(frVo.getFileWebUrl() + frVo.getFileWebPath()), frVo.fileWebDownloadUrl) ;
return BaseResponseUtils.buildSuccess(fvo) ;
}else {
return BaseResponseUtils.buildError("鏈緱鍒颁笂浼犳枃浠剁殑鎵╁睍鍚�");
@@ -73,7 +72,7 @@
@PostMapping("/upPhone")
@SsoPowerAop(power = "-1")
- public BaseResponse<?> upPhone(MultipartFile file, HttpServletRequest req) {
+ public BaseResponse<?> upPhone(MultipartFile file) {
try {
if (file != null) {
String[] fileNameGrp = fileOp.splitFileName(file) ;
@@ -87,8 +86,8 @@
fileNameGrp[1],
null);
String fileMainName = fileOp.getFileMainName(frVo.fileName) ;
- Long id = this.saveFileInfo(fileNameGrp[0], fileNameGrp[1], fileMainName, frVo.fileNameHash, frVo.fileWebPath);
- FileVo fvo = new FileVo(id, frVo.fileNameHash, fileNameGrp[0], fileNameGrp[1],frVo.getFileWebUrl() + frVo.getFileWebPath(), null) ;
+ Long id = this.saveFileInfo(fileNameGrp[0], fileNameGrp[1], fileMainName, frVo.fileNameHash, frVo.fileWebPath, frVo.fileWebDownloadUrl);
+ FileVo fvo = new FileVo(id, frVo.fileNameHash, fileNameGrp[0], fileNameGrp[1],frVo.getFileWebUrl() + frVo.getFileWebPath(), null, frVo.fileWebDownloadUrl) ;
return BaseResponseUtils.buildSuccess(fvo) ;
}else {
return BaseResponseUtils.buildError("鏈緱鍒颁笂浼犳枃浠剁殑鎵╁睍鍚�");
@@ -109,7 +108,7 @@
@PostMapping("/upVideo")
@SsoPowerAop(power = "-1")
- public BaseResponse<?> upVideo(MultipartFile file, HttpServletRequest req) {
+ public BaseResponse<?> upVideo(MultipartFile file) {
try {
if (file != null) {
String[] fileNameGrp = fileOp.splitFileName(file) ;
@@ -123,8 +122,8 @@
fileNameGrp[1],
null);
String fileMainName = fileOp.getFileMainName(frVo.fileName) ;
- Long id = this.saveFileInfo(fileNameGrp[0], fileNameGrp[1], fileMainName, frVo.fileNameHash, frVo.fileWebPath);
- FileVo fvo = new FileVo(id, frVo.fileNameHash, fileNameGrp[0], fileNameGrp[1],frVo.getFileWebUrl() + frVo.getFileWebPath(), null) ;
+ Long id = this.saveFileInfo(fileNameGrp[0], fileNameGrp[1], fileMainName, frVo.fileNameHash, frVo.fileWebPath, frVo.fileWebDownloadUrl);
+ FileVo fvo = new FileVo(id, frVo.fileNameHash, fileNameGrp[0], fileNameGrp[1],frVo.getFileWebUrl() + frVo.getFileWebPath(), null, frVo.fileWebDownloadUrl) ;
return BaseResponseUtils.buildSuccess(fvo) ;
}else {
return BaseResponseUtils.buildError("鏈緱鍒颁笂浼犳枃浠剁殑鎵╁睍鍚�");
@@ -145,7 +144,7 @@
@PostMapping("/upDocument")
@SsoPowerAop(power = "-1")
- public BaseResponse<?> upDocument(MultipartFile file, HttpServletRequest req) {
+ public BaseResponse<?> upDocument(MultipartFile file) {
try {
if (file != null) {
String[] fileNameGrp = fileOp.splitFileName(file) ;
@@ -159,8 +158,8 @@
fileNameGrp[1],
null);
String fileMainName = fileOp.getFileMainName(frVo.fileName) ;
- Long id = this.saveFileInfo(fileNameGrp[0], fileNameGrp[1], fileMainName, frVo.fileNameHash, frVo.fileWebPath);
- FileVo fvo = new FileVo(id, frVo.fileNameHash, fileNameGrp[0], fileNameGrp[1],frVo.getFileWebUrl() + frVo.getFileWebPath(), null) ;
+ Long id = this.saveFileInfo(fileNameGrp[0], fileNameGrp[1], fileMainName, frVo.fileNameHash, frVo.fileWebPath, frVo.fileWebDownloadUrl);
+ FileVo fvo = new FileVo(id, frVo.fileNameHash, fileNameGrp[0], fileNameGrp[1],frVo.getFileWebUrl() + frVo.getFileWebPath(), null, frVo.fileWebDownloadUrl) ;
return BaseResponseUtils.buildSuccess(fvo) ;
}else {
return BaseResponseUtils.buildError("鏈緱鍒颁笂浼犳枃浠剁殑鎵╁睍鍚�");
@@ -187,13 +186,14 @@
* @param filePath 鏂囦欢鏈嶅姟绔瓨鍌ㄧ浉瀵硅矾寰�
* @return
*/
- private Long saveFileInfo(String orgName, String extName, String newName, Integer hash, String filePath){
+ private Long saveFileInfo(String orgName, String extName, String newName, Integer hash, String filePath, String downloadPath){
OthFile po = new OthFile() ;
po.orgName = orgName ;
po.extName = extName ;
po.newName = newName ;
po.hash = hash ;
po.filePath = filePath ;
+ po.downloadPath = downloadPath ;
return this.sv.save(po) ;
}
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoOth/OthFile.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoOth/OthFile.java
index 8bc69f8..3abb84f 100644
--- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoOth/OthFile.java
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoOth/OthFile.java
@@ -1,50 +1,77 @@
package com.dy.pmsGlobal.pojoOth;
-import com.baomidou.mybatisplus.annotation.TableName;
+import com.alibaba.fastjson2.annotation.JSONField;
+import com.alibaba.fastjson2.writer.ObjectWriterImplToString;
+import com.baomidou.mybatisplus.annotation.*;
import com.dy.common.po.BaseEntity;
+import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.*;
+
+import java.util.Date;
/**
* 涓婅浇鐨勬枃浠朵俊鎭�
*/
-//2024-04-12涓嬮潰TableName涓嶇敤閰嶇疆琛ㄥ悕绉帮紙value="BaUser"鎴栤�渂a_user鈥濓級
-//鍙閫氳繃椹煎嘲鍛藉悕娉曞垯绫诲悕涓庤〃鍚嶅搴旇捣鏉ュ氨鍙互浜嗭紝濡傛灉涓嶈兘瀵瑰簲璧锋潵锛岄渶瑕佹寚瀹氳〃鍚嶇О
-//渚嬪@TableName(value="TestUser" autoResultMap = true)
-@TableName(value="ba_role", autoResultMap = true)
+
+@TableName(value="Oth_file", autoResultMap = true)
@Data
@Builder
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class OthFile implements BaseEntity {
+
+ public static final long serialVersionUID = 202404231631001L;
/**
- * 涓婚敭
+ * 涓婚敭
+ */
+ /* 濡傛灉涓嶆槑纭� type绫诲瀷锛孧P灏嗚嚜鍔ㄤ负鍏惰祴鍊硷紙闆姳ID锛�
+ IdType:
+ AUTO(0), //鑷
+ NONE(1), //鏈缃富閿�
+ INPUT(2), //鎵嬪姩杈撳叆
+ ASSIGN_ID(3), //榛樿鍏ㄥ眬鍞竴ID
+ ASSIGN_UUID(4), //鍏ㄥ眬鍞竴鐨� uuid
*/
+ @JSONField(serializeUsing= ObjectWriterImplToString.class)
+ @TableId(value = "id", type = IdType.INPUT)
public Long id;
/**
- * 鏂囦欢鍘熷悕绉�
- */
+ * 鏂囦欢鍘熷悕绉�
+ */
public String orgName;
/**
- * 鎵╁睍鍚�
- */
+ * 鎵╁睍鍚�
+ */
public String extName;
/**
- * 涓婁紶鏂囦欢鍚庣郴缁熻嚜鍔ㄧ粰鏂囦欢璧嬬殑鏂板悕绉�
- */
+ * 涓婁紶鏂囦欢鍚庣郴缁熻嚜鍔ㄧ粰鏂囦欢璧嬬殑鏂板悕绉�
+ */
public String newName;
/**
- * 鏂囦欢hash鍊�
- */
+ * 鏂囦欢hash鍊�
+ */
public Integer hash;
/**
- * 鏂囦欢鍦ㄦ湇鍔$瀛樺偍鐨勭浉瀵硅矾寰�
- */
+ * 鏂囦欢鍦ㄦ湇鍔$瀛樺偍鐨勭浉瀵硅矾寰�
+ */
public String filePath;
+ /**
+ * 鏂囦欢涓嬭浇璺緞
+ */
+ public String downloadPath;
+
+ /**
+ * 鏂囦欢涓婅浇鏃ユ湡
+ */
+ @TableField(value = "dt", fill = FieldFill.INSERT)
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ public Date dt;
+
}
\ No newline at end of file
diff --git a/pms-parent/pms-global/src/main/resources/application-global.yml b/pms-parent/pms-global/src/main/resources/application-global.yml
index bf9e58b..2b98a32 100644
--- a/pms-parent/pms-global/src/main/resources/application-global.yml
+++ b/pms-parent/pms-global/src/main/resources/application-global.yml
@@ -108,7 +108,7 @@
hashEnd: 5461
restUrl: http://127.0.0.1:${pms.file1.webPort}/file #file鏄笂涓嬫枃
webUrl: http://127.0.0.1:${pms.nginx.webPort}/webfiles/ #nginx鏈嶅姟璺緞
- webDownloadUrl: http://127.0.0.1:${pms.file1.webPort}/file/download/down
+ webDownloadUrl: http://127.0.0.1:${pms.file1.webPort}/file/download/down?id=
sv2:
id: dyFile2
absolutePath: E:/java/nginx-1.24.0/html/webfiles/
@@ -117,7 +117,7 @@
hashEnd: 10923
restUrl: http://127.0.0.1:${pms.file2.webPort}/file
webUrl: http://127.0.0.1:${pms.nginx.webPort}/webfiles/
- webDownloadUrl: http://127.0.0.1:${pms.file2.webPort}/file/download/down
+ webDownloadUrl: http://127.0.0.1:${pms.file2.webPort}/file/download/down?id=
sv3:
id: dyFile3
absolutePath: E:/java/nginx-1.24.0/html/webfiles/
@@ -126,7 +126,7 @@
hashEnd: 16385
restUrl: http://127.0.0.1:${pms.file3.webPort}/file
webUrl: http://127.0.0.1:${pms.nginx.webPort}/webfiles/
- webDownloadUrl: http://127.0.0.1:${pms.file3.webPort}/file/download/down
+ webDownloadUrl: http://127.0.0.1:${pms.file3.webPort}/file/download/down?id=
sv4:
id: dyFile4
absolutePath: E:/java/nginx-1.24.0/html/webfiles/
@@ -135,7 +135,7 @@
hashEnd: 21847
restUrl: http://127.0.0.1:${pms.file4.webPort}/file
webUrl: http://127.0.0.1:${pms.nginx.webPort}/webfiles/
- webDownloadUrl: http://127.0.0.1:${pms.file4.webPort}/file/download/down
+ webDownloadUrl: http://127.0.0.1:${pms.file4.webPort}/file/download/down?id=
sv5:
id: dyFile5
absolutePath: E:/java/nginx-1.24.0/html/webfiles/
@@ -144,7 +144,7 @@
hashEnd: 27309
restUrl: http://127.0.0.1:${pms.file5.webPort}/file
webUrl: http://127.0.0.1:${pms.nginx.webPort}/webfiles/
- webDownloadUrl: http://127.0.0.1:${pms.file5.webPort}/file/download/down
+ webDownloadUrl: http://127.0.0.1:${pms.file5.webPort}/file/download/down?id=
sv6:
id: dyFile6
absolutePath: E:/java/nginx-1.24.0/html/webfiles/
@@ -153,7 +153,7 @@
hashEnd: 32767
restUrl: http://127.0.0.1:${pms.file6.webPort}/file
webUrl: http://127.0.0.1:${pms.nginx.webPort}/webfiles/
- webDownloadUrl: http://127.0.0.1:${pms.file6.webPort}/file/download/down
+ webDownloadUrl: http://127.0.0.1:${pms.file6.webPort}/file/download/down?id=
sv7:
id: dyFile7
absolutePath: E:/java/nginx-1.24.0/html/webfiles/
@@ -162,7 +162,7 @@
hashEnd: 38229
restUrl: http://127.0.0.1:${pms.file7.webPort}/file
webUrl: http://127.0.0.1:${pms.nginx.webPort}/webfiles/
- webDownloadUrl: http://127.0.0.1:${pms.file7.webPort}/file/download/down
+ webDownloadUrl: http://127.0.0.1:${pms.file7.webPort}/file/download/down?id=
sv8:
id: dyFile8
absolutePath: E:/java/nginx-1.24.0/html/webfiles/
@@ -171,7 +171,7 @@
hashEnd: 43691
restUrl: http://127.0.0.1:${pms.file8.webPort}/file
webUrl: http://127.0.0.1:${pms.nginx.webPort}/webfiles/
- webDownloadUrl: http://127.0.0.1:${pms.file8.webPort}/file/download/down
+ webDownloadUrl: http://127.0.0.1:${pms.file8.webPort}/file/download/down?id=
sv9:
id: dyFile9
absolutePath: E:/java/nginx-1.24.0/html/webfiles/
@@ -180,7 +180,7 @@
hashEnd: 49153
restUrl: http://127.0.0.1:${pms.file9.webPort}/file
webUrl: http://127.0.0.1:${pms.nginx.webPort}/webfiles/
- webDownloadUrl: http://127.0.0.1:${pms.file9.webPort}/file/download/down
+ webDownloadUrl: http://127.0.0.1:${pms.file9.webPort}/file/download/down?id=
sv10:
id: dyFile10
absolutePath: E:/java/nginx-1.24.0/html/webfiles/
@@ -189,7 +189,7 @@
hashEnd: 54615
restUrl: http://127.0.0.1:${pms.file10.webPort}/file
webUrl: http://127.0.0.1:${pms.nginx.webPort}/webfiles/
- webDownloadUrl: http://127.0.0.1:${pms.file10.webPort}/file/download/down
+ webDownloadUrl: http://127.0.0.1:${pms.file10.webPort}/file/download/down?id=
sv11:
id: dyFile11
absolutePath: E:/java/nginx-1.24.0/html/webfiles/
@@ -198,7 +198,7 @@
hashEnd: 60077
restUrl: http://127.0.0.1:${pms.file11.webPort}/file
webUrl: http://127.0.0.1:${pms.nginx.webPort}/webfiles/
- webDownloadUrl: http://127.0.0.1:${pms.file11.webPort}/file/download/down
+ webDownloadUrl: http://127.0.0.1:${pms.file11.webPort}/file/download/down?id=
sv12:
id: dyFile12
absolutePath: E:/java/nginx-1.24.0/html/webfiles/
@@ -207,4 +207,4 @@
hashEnd: 65535
restUrl: http://127.0.0.1:${pms.file12.webPort}/file
webUrl: http://127.0.0.1:${pms.nginx.webPort}/webfiles/
- webDownloadUrl: http://127.0.0.1:${pms.file12.webPort}/file/download/down
+ webDownloadUrl: http://127.0.0.1:${pms.file12.webPort}/file/download/down?id=
diff --git a/pms-parent/pms-global/src/main/resources/mapper/OthFileMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/OthFileMapper.xml
index 2ce8b6c..79591c6 100644
--- a/pms-parent/pms-global/src/main/resources/mapper/OthFileMapper.xml
+++ b/pms-parent/pms-global/src/main/resources/mapper/OthFileMapper.xml
@@ -10,10 +10,12 @@
<result column="new_name" property="newName" />
<result column="hash" property="hash" />
<result column="file_path" property="filePath" />
+ <result column="download_path" property="downloadPath" />
+ <result column="dt" property="dt" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
- id, org_name, ext_name, new_name, hash, file_path
+ id, org_name, ext_name, new_name, hash, file_path, download_path, dt
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
<!--@mbg.generated-->
@@ -29,8 +31,10 @@
</delete>
<insert id="insert" parameterType="com.dy.pmsGlobal.pojoOth.OthFile">
<!--@mbg.generated-->
- insert into oth_file (id, org_name, ext_name, new_name, hash, file_path)
- values (#{id}, #{orgName}, #{extName}, #{newName}, #{hash}, #{filePath})
+ insert into oth_file (id, org_name, ext_name, new_name, hash, file_path, download_path,
+ dt)
+ values (#{id}, #{orgName}, #{extName}, #{newName}, #{hash}, #{filePath}, #{downloadPath},
+ #{dt})
</insert>
<insert id="insertSelective" parameterType="com.dy.pmsGlobal.pojoOth.OthFile">
<!--@mbg.generated-->
@@ -54,6 +58,12 @@
<if test="filePath != null">
file_path,
</if>
+ <if test="downloadPath != null">
+ download_path,
+ </if>
+ <if test="dt != null">
+ dt,
+ </if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@@ -73,6 +83,12 @@
</if>
<if test="filePath != null">
#{filePath},
+ </if>
+ <if test="downloadPath != null">
+ #{downloadPath},
+ </if>
+ <if test="dt != null">
+ #{dt},
</if>
</trim>
</insert>
@@ -95,6 +111,12 @@
<if test="filePath != null">
file_path = #{filePath},
</if>
+ <if test="downloadPath != null">
+ download_path = #{downloadPath},
+ </if>
+ <if test="dt != null">
+ dt = #{dt},
+ </if>
</set>
where id = #{id}
</update>
@@ -105,7 +127,9 @@
ext_name = #{extName},
new_name = #{newName},
hash = #{hash},
- file_path = #{filePath}
+ file_path = #{filePath},
+ download_path = #{downloadPath},
+ dt = #{dt}
where id = #{id}
</update>
</mapper>
\ No newline at end of file
diff --git a/pms-parent/pms-web-file/src/main/java/com/dy/dyFile/download/DownloadFileCtr.java b/pms-parent/pms-web-file/src/main/java/com/dy/dyFile/download/DownloadFileCtr.java
deleted file mode 100644
index 912fead..0000000
--- a/pms-parent/pms-web-file/src/main/java/com/dy/dyFile/download/DownloadFileCtr.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.dy.dyFile.download;
-
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * web鏂囦欢涓嬭浇
- */
-@Slf4j
-@RestController
-@RequestMapping(path="download")
-@SuppressWarnings("unchecked")//java鐗堟湰瓒婇珮锛屽娉涘瀷绾︽潫瓒婁弗锛屾墍浠ラ厤缃甋uppressWarnings("unchecked")
-public class DownloadFileCtr {
- public String down(){
- return null ;
- }
-}
diff --git a/pms-parent/pms-web-file/src/main/java/com/dy/dyFile/download/DownloadFileCtrl.java b/pms-parent/pms-web-file/src/main/java/com/dy/dyFile/download/DownloadFileCtrl.java
new file mode 100644
index 0000000..57f5648
--- /dev/null
+++ b/pms-parent/pms-web-file/src/main/java/com/dy/dyFile/download/DownloadFileCtrl.java
@@ -0,0 +1,108 @@
+package com.dy.dyFile.download;
+
+import cn.hutool.http.server.HttpServerResponse;
+import com.dy.pmsGlobal.dyFile.FileOperate;
+import com.dy.pmsGlobal.dyFile.FileRestVo;
+import com.dy.pmsGlobal.pojoOth.OthFile;
+import jakarta.servlet.ServletOutputStream;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+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.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.io.File;
+import java.io.FileInputStream;
+
+/**
+ * web鏂囦欢涓嬭浇
+ */
+@Slf4j
+@RestController
+@RequestMapping(path="download")
+@SuppressWarnings("unchecked")//java鐗堟湰瓒婇珮锛屽娉涘瀷绾︽潫瓒婁弗锛屾墍浠ラ厤缃甋uppressWarnings("unchecked")
+public class DownloadFileCtrl {
+
+ @Autowired
+ private DownloadFileSv sv ;
+
+ @Autowired
+ private FileOperate fileOp ;
+
+ @Value("${dy.webFile.fmUrl}")
+ private String fmUrl ;
+
+
+ /**
+ * 閫氳繃web鏂囦欢鏁版嵁搴撳疄浣搃d涓嬭浇璇ユ枃浠�
+ * @param id
+ * @return
+ */
+ @GetMapping("/down")
+ public void down(String id, HttpServletRequest req, HttpServletResponse rep){
+ OthFile fPo = sv.selectById(id) ;
+ if(fPo != null){
+ FileRestVo frVo = fileOp.parseHashcode(fmUrl, fPo.hash) ;
+ if(frVo.fileSysAbsolutePath != null){
+ if(!frVo.fileSysAbsolutePath.endsWith("\\\\") && !frVo.fileSysAbsolutePath.endsWith("/") ){
+ frVo.fileSysAbsolutePath = frVo.fileSysAbsolutePath + "/" ;
+ }
+ }
+ String filePath = frVo.fileSysAbsolutePath + fPo.filePath ;
+ File f = new File(filePath) ;
+ if(f.exists()){
+ String fileReName = fPo.orgName + "." + fPo.extName ;
+ try {
+ fileReName = new String(fileReName.getBytes("UTF-8"), "ISO-8859-1");
+ } catch (Exception e) {
+ fileReName = "file" ;
+ }
+ rep.addHeader("content-type", "application/octet-stream");
+ rep.addHeader("Content-Disposition", "attachment;fileName=" + fileReName);
+
+ ServletOutputStream out = null;
+ FileInputStream in = null ;
+ try {
+ out = rep.getOutputStream() ;
+ } catch (Exception ee) {
+ out = null ;
+ }finally{
+ if(out != null){
+ byte[] bs = new byte[1024] ;
+ int len = -1 ;
+ try {
+ in = new FileInputStream(f);
+ len = in.read(bs) ;
+ while(len != -1){
+ out.write(bs, 0, len);
+ len = in.read(bs) ;
+ }
+ } catch (Exception eee) {
+ } finally {
+ if(out != null){
+ try{
+ out.flush();
+ out.close();
+ }catch(Exception e){
+ }finally{
+ if(in != null){
+ try{
+ in.close();
+ }catch(Exception e){
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }else{
+ }
+ }else{
+ }
+ }
+}
diff --git a/pms-parent/pms-web-file/src/main/java/com/dy/dyFile/download/DownloadFileSv.java b/pms-parent/pms-web-file/src/main/java/com/dy/dyFile/download/DownloadFileSv.java
new file mode 100644
index 0000000..a19981e
--- /dev/null
+++ b/pms-parent/pms-web-file/src/main/java/com/dy/dyFile/download/DownloadFileSv.java
@@ -0,0 +1,32 @@
+package com.dy.dyFile.download;
+
+
+import com.dy.common.util.NumUtil;
+import com.dy.pmsGlobal.daoBa.BaUserMapper;
+import com.dy.pmsGlobal.daoOth.OthFileMapper;
+import com.dy.pmsGlobal.pojoOth.OthFile;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+@Slf4j
+@Service
+public class DownloadFileSv {
+ @Autowired
+ private OthFileMapper dao;
+
+ /**
+ * 鐢↖D鏌ヨ
+ * @param id
+ * @return
+ */
+ public OthFile selectById(String id){
+ if(NumUtil.isPlusIntNumber(id)){
+ return dao.selectByPrimaryKey(Long.parseLong(id)) ;
+ }else{
+ return null ;
+ }
+ }
+
+}
diff --git a/pms-parent/pms-web-file/src/main/java/com/dy/dyFile/files/FileCtrl.java b/pms-parent/pms-web-file/src/main/java/com/dy/dyFile/files/FileCtrl.java
index 5e85b07..c41d614 100644
--- a/pms-parent/pms-web-file/src/main/java/com/dy/dyFile/files/FileCtrl.java
+++ b/pms-parent/pms-web-file/src/main/java/com/dy/dyFile/files/FileCtrl.java
@@ -13,7 +13,8 @@
import java.io.InputStream;
/**
- * web鏂囦欢涓婁紶
+ * web鏂囦欢涓婁紶, 鍐呴儴璋冪敤锛屽嵆鐢卞叾浠栧瓙妯″潡璋冪敤锛�
+ * 涓�鑸笉鐢卞墠绔郴缁熻皟鐢�
*/
@Slf4j
@RestController
diff --git a/pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/dyFm/DyFileSvConf.java b/pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/dyFm/DyFileSvConf.java
index 6e314ec..7b55078 100644
--- a/pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/dyFm/DyFileSvConf.java
+++ b/pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/dyFm/DyFileSvConf.java
@@ -101,12 +101,8 @@
}
if(this.webDownloadUrl == null || this.webDownloadUrl.trim().equals("")){
throw new Exception("鍑洪敊锛寃ebDownloadUrl涓虹┖浜嗭紒") ;
- }else{
- this.webDownloadUrl = this.webDownloadUrl.trim() ;
- if(!this.webDownloadUrl.endsWith("/") && !this.webDownloadUrl.endsWith("\\")){
- this.webDownloadUrl += "/" ;
- }
}
+
if(this.hashStart == null){
throw new Exception("鍑洪敊锛宧ashStart涓虹┖浜嗭紒") ;
}else if(this.hashStart.intValue() < 0){
--
Gitblit v1.8.0