From c7181cd5ecbf3e3bfcbd409bb8fb9818d5300050 Mon Sep 17 00:00:00 2001
From: wangsixiang <2970484253@qq.com>
Date: Fri, 14 Jun 2024 08:30:56 +0800
Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0,=E6=8E=A8?=
=?UTF-8?q?=E9=80=81=E9=AA=8C=E8=AF=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
zc-business/pom.xml | 4 +++
.../controller/DcFileDownloadController.java | 33 ++++++++++++++++++-
.../zc/business/controller/MsmController.java | 5 ++-
3 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/zc-business/pom.xml b/zc-business/pom.xml
index 8985c944..b185377e 100644
--- a/zc-business/pom.xml
+++ b/zc-business/pom.xml
@@ -94,6 +94,10 @@
jsoup
1.15.3
+
+ com.ruoyi
+ ruoyi-framework
+
com.zc
diff --git a/zc-business/src/main/java/com/zc/business/controller/DcFileDownloadController.java b/zc-business/src/main/java/com/zc/business/controller/DcFileDownloadController.java
index 9d5397f6..369a3afb 100644
--- a/zc-business/src/main/java/com/zc/business/controller/DcFileDownloadController.java
+++ b/zc-business/src/main/java/com/zc/business/controller/DcFileDownloadController.java
@@ -3,6 +3,9 @@ package com.zc.business.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
+import com.ruoyi.common.config.RuoYiConfig;
+import com.ruoyi.common.utils.file.FileUploadUtils;
+import com.ruoyi.common.utils.file.FileUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@@ -21,6 +24,8 @@ import com.zc.business.domain.DcFileDownload;
import com.zc.business.service.IDcFileDownloadService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.framework.config.ServerConfig;
+import org.springframework.web.multipart.MultipartFile;
/**
* 文件管理Controller
@@ -33,7 +38,8 @@ import com.ruoyi.common.core.page.TableDataInfo;
public class DcFileDownloadController extends BaseController {
@Autowired
private IDcFileDownloadService dcFileDownloadService;
-
+ @Autowired
+ private ServerConfig serverConfig;
/**
* 查询文件管理列表
*/
@@ -95,4 +101,29 @@ public class DcFileDownloadController extends BaseController {
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(dcFileDownloadService.deleteDcFileDownloadByIds(ids));
}
+ /**
+ * 文件管理-文件上传请求
+ */
+ @PostMapping("/uploadFileManagement")
+ public AjaxResult uploadFileManagement(MultipartFile file) throws Exception
+ {
+ try
+ {
+ // 上传文件路径
+ String filePath = RuoYiConfig.getFileManagementPath();
+ // 上传并返回新文件名称
+ String fileName = FileUploadUtils.upload(filePath, file);
+ String url = serverConfig.getUrl() + 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());
+ }
+ }
}
diff --git a/zc-business/src/main/java/com/zc/business/controller/MsmController.java b/zc-business/src/main/java/com/zc/business/controller/MsmController.java
index a89d5c64..bc35521e 100644
--- a/zc-business/src/main/java/com/zc/business/controller/MsmController.java
+++ b/zc-business/src/main/java/com/zc/business/controller/MsmController.java
@@ -59,6 +59,9 @@ public class MsmController extends BaseController {
if (!map.containsKey("eventId")|| StringUtils.isBlank(map.get("eventId").toString())) {
return AjaxResult.error("事件id为空");
}
+ if (map.get("content").toString().length()>=200){
+ return AjaxResult.error("内容长度超长");
+ }
return msmService.putAll(map);
}
//整合推送(弃用)
@@ -116,4 +119,4 @@ public class MsmController extends BaseController {
}
}
-}
\ No newline at end of file
+}