From 2a71968dfe4637156cbdf702a109634d08fe6d93 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期四, 06 十一月 2025 13:55:06 +0800
Subject: [PATCH] 代码提交

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java |   50 ++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 44 insertions(+), 6 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java
index 7d34762..9786459 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java
@@ -10,6 +10,8 @@
 import com.ruoyi.common.utils.file.FileUploadUtils;
 import com.ruoyi.common.utils.file.FileUtils;
 import com.ruoyi.framework.config.ServerConfig;
+import com.ruoyi.system.domain.SysConfig;
+import com.ruoyi.system.mapper.SysConfigMapper;
 import com.smartor.domain.HtmlContentVO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -54,10 +56,22 @@
     @Autowired
     private ServerConfig serverConfig;
 
+    @Autowired
+    private SysConfigMapper sysConfigMapper;
+
     private static final String FILE_DELIMETER = ",";
 
     @Value("${uploadSwitch}")
     private Integer uploadSwitch;
+
+    @Value("${fileUpload}")
+    private String fileUpload;
+
+    @Value("${profile}")
+    private String profile;
+
+    @Value("${spring.profiles.active}")
+    private String active;
 
     /**
      * 閫氱敤涓嬭浇璇锋眰
@@ -107,8 +121,8 @@
             // 涓婁紶骞惰繑鍥炴柊鏂囦欢鍚嶇О
             String fileName = FileUploadUtils.uploadSort(filePath, file);
             String url = null;
-            //鏂板崕鍖婚櫌鐗规畩锛岃繖涓棰戠殑璁块棶寰楄浆
-            String xhPath = "http://218.108.11.22:8093/profile-api";
+            String xhPath = fileUpload + profile;
+
             if (uploadSwitch == 1) {
                 String fn = fileName.replaceAll("/profile", "");
                 url = xhPath + fn;
@@ -143,7 +157,10 @@
             convertDocToHtml(filePath + "\\" + file.getOriginalFilename(), filePath + "\\" + file.getOriginalFilename().split("\\.", 2)[0] + ".html");
 
             String url = null;
-            String xhPath = "http://218.108.11.22:8093/profile-api";
+            SysConfig config = new SysConfig();
+            config.setConfigKey("sys.qdip");
+            SysConfig sysConfig = sysConfigMapper.selectConfig(config);
+            String xhPath = sysConfig.getConfigValue() + "/profile-api";
             if (uploadSwitch == 1) {
                 String fn = fileName.replaceAll("\\.[^.]*$", ".html").replaceAll("/profile", "");
                 url = xhPath + fn;
@@ -263,13 +280,12 @@
         // 灏嗘枃浠朵繚瀛樺埌鎸囧畾鐩綍
         File outputFile = new File(RuoYiConfig.getUploadPath() + "/show/" + fileName.split("\\.", 2)[0] + "/" + fileName);
         try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile), "UTF-8"))) {
-            if (StringUtils.isNotEmpty(htmlContentVO.getContent()))
-                writer.write(htmlContentVO.getContent());
+            if (StringUtils.isNotEmpty(htmlContentVO.getContent())) writer.write(htmlContentVO.getContent());
         } catch (IOException e) {
             e.printStackTrace();
         }
         String url = null;
-        String xhPath = "http://218.108.11.22:8093/profile-api";
+        String xhPath = fileUpload + profile;
         if (uploadSwitch == 1) {
             url = xhPath + "/upload/show/" + fileName.split("\\.", 2)[0] + "/" + fileName;
         } else {
@@ -315,4 +331,26 @@
     }
 
 
+    /**
+     * 鑾峰彇鏂囦欢鎵╁睍鍚�
+     */
+    private static String getFileExtension(String fileName) {
+        int lastDotIndex = fileName.lastIndexOf('.');
+        if (lastDotIndex > 0) {
+            return fileName.substring(lastDotIndex);
+        }
+        return "";
+    }
+
+    /**
+     * 妫�鏌ユ枃浠舵槸鍚︿负鏀寔鐨刉ord鏍煎紡
+     */
+    public static boolean isSupportedWordFormat(String filePath) {
+        if (filePath == null) return false;
+        String fileName = filePath.toLowerCase();
+        return fileName.endsWith(".doc") || fileName.endsWith(".docx");
+    }
 }
+
+
+

--
Gitblit v1.9.3