From f90c70b7cfe4492df2e12433f960717ca47f7852 Mon Sep 17 00:00:00 2001
From: wujianwei <wjw@11.com>
Date: 星期二, 23 十二月 2025 17:48:10 +0800
Subject: [PATCH] 应付接口

---
 admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java |   34 ++++++++++++++++++++++++++++++++--
 1 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java b/admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java
index a6952cc..d4ac2ba 100644
--- a/admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java
+++ b/admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java
@@ -1,7 +1,9 @@
 package com.ruoyi.web.controller.common;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
@@ -11,6 +13,7 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.MediaType;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -40,6 +43,9 @@
     private ServerConfig serverConfig;
 
     private static final String FILE_DELIMETER = ",";
+
+    @Value("${custom.upload.network-path}")
+    private String networkPath;
 
     @Autowired
     private RedisCache redisCache;
@@ -109,12 +115,36 @@
             String filePath = RuoYiConfig.getUploadPath();
             // 涓婁紶骞惰繑鍥炴柊鏂囦欢鍚嶇О
             String fileName = FileUploadUtils.upload(filePath, file);
-            String url = serverConfig.getUrl() + fileName;
+            String url = networkPath + fileName;
             AjaxResult ajax = AjaxResult.success();
             ajax.put("url", url);
             ajax.put("fileName", fileName);
             ajax.put("newFileName", FileUtils.getName(fileName));
             ajax.put("originalFilename", file.getOriginalFilename());
+            return ajax;
+        }
+        catch (Exception e)
+        {
+            return AjaxResult.error(e.getMessage());
+        }
+    }
+    @PostMapping("/upload2")
+    public AjaxResult uploadFile2(MultipartFile file) throws Exception
+    {
+        try
+        {
+            // 涓婁紶鏂囦欢璺緞
+            String filePath = RuoYiConfig.getUploadPath();
+            // 涓婁紶骞惰繑鍥炴柊鏂囦欢鍚嶇О
+            String fileName = FileUploadUtils.upload(filePath, file);
+            String url = networkPath + fileName;
+            HashMap<String, Object> stringObjectHashMap = new HashMap<>();
+            stringObjectHashMap.put("url", url);
+            stringObjectHashMap.put("name", FileUtils.getName(fileName));
+//            stringObjectHashMap.put("newFileName", FileUtils.getName(fileName));
+//            stringObjectHashMap.put("originalFilename", file.getOriginalFilename());
+            AjaxResult ajax = AjaxResult.success(stringObjectHashMap);
+
             return ajax;
         }
         catch (Exception e)
@@ -141,7 +171,7 @@
             {
                 // 涓婁紶骞惰繑鍥炴柊鏂囦欢鍚嶇О
                 String fileName = FileUploadUtils.upload(filePath, file);
-                String url = serverConfig.getUrl() + fileName;
+                String url = networkPath + fileName;
                 urls.add(url);
                 fileNames.add(fileName);
                 newFileNames.add(FileUtils.getName(fileName));

--
Gitblit v1.8.0