From 672ce84d5ce6545a0e81709ea736c69cbbef8c1a Mon Sep 17 00:00:00 2001
From: zjh <1084500556@qq.com>
Date: 星期四, 24 四月 2025 18:12:47 +0800
Subject: [PATCH] zjh20250424

---
 ltkj-admin/src/main/java/com/ltkj/web/config/captcha/CommonController.java |   44 ++++++++++++++++++++++++++++++++++++++------
 1 files changed, 38 insertions(+), 6 deletions(-)

diff --git a/ltkj-admin/src/main/java/com/ltkj/web/config/captcha/CommonController.java b/ltkj-admin/src/main/java/com/ltkj/web/config/captcha/CommonController.java
index a480f19..9f1dbfd 100644
--- a/ltkj-admin/src/main/java/com/ltkj/web/config/captcha/CommonController.java
+++ b/ltkj-admin/src/main/java/com/ltkj/web/config/captcha/CommonController.java
@@ -2,10 +2,10 @@
 
 import java.io.File;
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.*;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
@@ -48,6 +48,9 @@
 
     @Autowired
     private ServerConfig serverConfig;
+
+    @Value("${path.xdtfilePath}")
+    private String value;
 
     private static final String FILE_DELIMETER = ",";
 
@@ -92,8 +95,8 @@
     }
 
     /**
-    *   閲嶆柊鍐欑殑涓婁紶鍥剧墖   閫傜敤浜庝綋妫�濂楅
-    */
+     *   閲嶆柊鍐欑殑涓婁紶鍥剧墖   閫傜敤浜庝綋妫�濂楅
+     */
     @PostMapping("/packageUpload")
     public AjaxResult packageUpload(@RequestBody MultipartFile file) {
         String fileName = file.getOriginalFilename();
@@ -274,4 +277,33 @@
         }
         return AjaxResult.success("鍒犻櫎鎴愬姛");
     }
+
+
+
+    /**
+     * 蹇冪數鍥炬姤鍛婁笂浼犲浘鐗囨柟娉�
+     */
+    @PostMapping("/uploadXdtFile")
+    @ApiOperation(value = "蹇冪數鍥炬姤鍛婁笂浼犲浘鐗囨柟娉�")
+    public AjaxResult uploadXdtFile(@ApiParam("鏂囦欢") @RequestPart("file") MultipartFile file,
+                                    @ApiParam("浣撴鍙�") String tjh,@ApiParam("椤圭洰id") String proId) throws Exception {
+        try {
+            // 涓婁紶鏂囦欢璺緞
+            String filePath = value + File.separator;
+            String outputFileName = tjh +"_" +proId;
+            // 涓婁紶骞惰繑鍥炴柊鏂囦欢鍚嶇О
+            String fileName = FileUploadUtils.upload(filePath,outputFileName, file);
+            String url = filePath + fileName;
+            Path path = Paths.get(url);
+            byte[] data = Files.readAllBytes(path);
+            String base64 = Base64.getEncoder().encodeToString(data);
+            AjaxResult ajax = AjaxResult.success();
+            ajax.put("url", url);
+            ajax.put("fileName", fileName);
+            ajax.put("base64", base64);
+            return ajax;
+        } catch (Exception e) {
+            return AjaxResult.error(e.getMessage());
+        }
+    }
 }

--
Gitblit v1.8.0