Administrator 1 год назад
Родитель
Сommit
df052e6b78

+ 56 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/UEditorController.java

@@ -0,0 +1,56 @@
+package com.ruoyi.web.controller.common;
+
+import com.ruoyi.system.domain.Ueditor;
+import com.ruoyi.system.service.impl.UploadService;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+
+/**
+ * 百度富文本编辑器
+ * @Author: tjf
+ * @Date: 2023/10/13 10:35
+ * @Describe:
+ */
+@RestController
+@RequestMapping("/ueditor")
+@CrossOrigin
+public class UEditorController {
+
+
+    @Resource
+    UploadService uploadFile;
+
+    @RequestMapping(value = "/upload")
+    @ResponseBody
+    public Object server(String action, String callback, MultipartFile upfile, HttpServletResponse response) {
+        Object result = null;
+        switch (action) {
+            case Ueditor.ACTION_CONFIG:
+                String result1 = "";
+                if (callback != null) {
+                    result1 = callback + "(" + Ueditor.UEDITOR_CONFIG + ")";
+                } else {
+                    result1 = Ueditor.UEDITOR_CONFIG;
+                }
+                try {
+                    response.getWriter().write(result1);//返回的十回调函数
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+                break;
+            case Ueditor.ACTION_UPLOADFILE:
+            case Ueditor.ACTION_UPLOADVIDEO:
+            case Ueditor.ACTION_UPLOADIMAGE:
+                Ueditor ueditor = uploadFile.uploadPicForUeditor(upfile);
+                result = ueditor;
+                break;
+            default:
+        }
+        return result;
+    }
+}

+ 3 - 27
ruoyi-common/pom.xml

@@ -133,33 +133,9 @@
         </dependency>
         <!--百度编译器核心包-->
         <dependency>
-            <groupId>ueditor-1.1.2</groupId>
-            <artifactId>ueditor-1.1.2</artifactId>
-            <version>1.1.2</version>
-            <scope>system</scope>
-            <systemPath>${pom.basedir}/src/main/java/lib/ueditor-1.1.2.jar</systemPath>
-        </dependency>
-
-        <dependency>
-            <groupId>commons-codec-1.9</groupId>
-            <artifactId>commons-codec-1.9</artifactId>
-            <version>1.1.2</version>
-            <scope>system</scope>
-            <systemPath>${pom.basedir}/src/main/java/lib/commons-codec-1.9.jar</systemPath>
-        </dependency>
-        <dependency>
-            <groupId>commons-fileupload-1.3.1</groupId>
-            <artifactId>commons-fileupload-1.3.1</artifactId>
-            <version>1.1.2</version>
-            <scope>system</scope>
-            <systemPath>${pom.basedir}/src/main/java/lib/commons-fileupload-1.3.1.jar</systemPath>
-        </dependency>
-        <dependency>
-            <groupId>json</groupId>
-            <artifactId>json</artifactId>
-            <version>1.1.2</version>
-            <scope>system</scope>
-            <systemPath>${pom.basedir}/src/main/java/lib/json.jar</systemPath>
+            <groupId>com.gitee.qdbp.thirdparty</groupId>
+            <artifactId>ueditor</artifactId>
+            <version>1.4.3.3</version>
         </dependency>
     </dependencies>
 

BIN
ruoyi-common/src/main/java/lib/commons-codec-1.9.jar


BIN
ruoyi-common/src/main/java/lib/commons-fileupload-1.3.1.jar


BIN
ruoyi-common/src/main/java/lib/commons-io-2.4.jar


BIN
ruoyi-common/src/main/java/lib/json.jar


BIN
ruoyi-common/src/main/java/lib/ueditor-1.1.2.jar


+ 1 - 1
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java

@@ -112,7 +112,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
                 .authorizeRequests()
                 // 对于登录login 注册register 验证码captchaImage 允许匿名访问
                 .antMatchers("/login", "/register", "/captchaImage").permitAll()
-                .antMatchers("/investigate/**","/investigate/disposition/**","/common/**").permitAll()
+                .antMatchers("/investigate/**","/investigate/disposition/**").permitAll()
                 .antMatchers("/login", "/register", "/captchaImage","/common/filetext").permitAll()
                 // 静态资源,可匿名访问
                 .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()

+ 122 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/Ueditor.java

@@ -0,0 +1,122 @@
+package com.ruoyi.system.domain;
+
+/**
+ * @Author: tjf
+ * @Date: 2023/10/13 11:24
+ * @Describe:
+ */
+
+public class Ueditor {
+        //前端传过来的参数,用于区分是什么请求
+        public final static String ACTION_CONFIG = "config";
+        public final static String ACTION_UPLOADIMAGE = "uploadimage";
+        public final static String ACTION_UPLOADVIDEO = "uploadvideo";
+        public final static String ACTION_UPLOADFILE = "uploadfile";
+        //后端返给前端的参数,需要时特定格式
+        public final static String ACTION_SUCCESS = "SUCCESS";
+        public final static String ACTION_FAIL = "FAIL";
+        private  String state;
+        private  String url;
+        private  String title;
+        private  String original;
+
+        //关键,假装自己是jsp的东西
+        public final static String UEDITOR_CONFIG = "{\n" +
+                "    \"imageActionName\": \"uploadimage\",\n" +
+                "    \"imageFieldName\": \"upfile\", \n" +
+                "    \"imageMaxSize\": 2048000, \n" +
+                "    \"imageAllowFiles\": [\".png\", \".jpg\", \".jpeg\", \".gif\", \".bmp\"],\n" +
+                "    \"imageCompressEnable\": true, \n" +
+                "    \"imageCompressBorder\": 1600, \n" +
+                "    \"imageInsertAlign\": \"none\", \n" +
+                "    \"imageUrlPrefix\": \"\", \n" +
+                "    \"imagePathFormat\": \"/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}\",\n" +
+                "    \"scrawlActionName\": \"uploadscrawl\",\n" +
+                "    \"scrawlFieldName\": \"upfile\", \n" +
+                "    \"scrawlPathFormat\": \"/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}\",\n" +
+                "    \"scrawlMaxSize\": 2048000,\n" +
+                "    \"scrawlUrlPrefix\": \"\",\n" +
+                "    \"scrawlInsertAlign\": \"none\",\n" +
+                "    \"snapscreenActionName\": \"uploadimage\", \n" +
+                "    \"snapscreenPathFormat\": \"/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}\",\n" +
+                "    \"snapscreenUrlPrefix\": \"\", \n" +
+                "    \"snapscreenInsertAlign\": \"none\",\n" +
+                "    \"catcherLocalDomain\": [\"127.0.0.1\", \"localhost\", \"img.baidu.com\"],\n" +
+                "    \"catcherActionName\": \"catchimage\", \n" +
+                "    \"catcherFieldName\": \"source\",\n" +
+                "    \"catcherPathFormat\": \"/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}\",\n" +
+                "    \"catcherUrlPrefix\": \"\", \n" +
+                "    \"catcherMaxSize\": 2048000, \n" +
+                "    \"catcherAllowFiles\": [\".png\", \".jpg\", \".jpeg\", \".gif\", \".bmp\"], \n" +
+                "    \"videoActionName\": \"uploadvideo\",\n" +
+                "    \"videoFieldName\": \"upfile\",\n" +
+                "    \"videoPathFormat\": \"/ueditor/jsp/upload/video/{yyyy}{mm}{dd}/{time}{rand:6}\",\n" +
+                "    \"videoUrlPrefix\": \"\",\n" +
+                "    \"videoMaxSize\": 102400000, \n" +
+                "    \"videoAllowFiles\": [\n" +
+                "        \".flv\", \".swf\", \".mkv\", \".avi\", \".rm\", \".rmvb\", \".mpeg\", \".mpg\",\n" +
+                "        \".ogg\", \".ogv\", \".mov\", \".wmv\", \".mp4\", \".webm\", \".mp3\", \".wav\", \".mid\"], \n" +
+                "    \"fileActionName\": \"uploadfile\", \n" +
+                "    \"fileFieldName\": \"upfile\",\n" +
+                "    \"filePathFormat\": \"/ueditor/jsp/upload/file/{yyyy}{mm}{dd}/{time}{rand:6}\", \n" +
+                "    \"fileUrlPrefix\": \"\",\n" +
+                "    \"fileMaxSize\": 51200000, \n" +
+                "    \"fileAllowFiles\": [\n" +
+                "        \".png\", \".jpg\", \".jpeg\", \".gif\", \".bmp\",\n" +
+                "        \".flv\", \".swf\", \".mkv\", \".avi\", \".rm\", \".rmvb\", \".mpeg\", \".mpg\",\n" +
+                "        \".ogg\", \".ogv\", \".mov\", \".wmv\", \".mp4\", \".webm\", \".mp3\", \".wav\", \".mid\",\n" +
+                "        \".rar\", \".zip\", \".tar\", \".gz\", \".7z\", \".bz2\", \".cab\", \".iso\",\n" +
+                "        \".doc\", \".docx\", \".xls\", \".xlsx\", \".ppt\", \".pptx\", \".pdf\", \".txt\", \".md\", \".xml\"\n" +
+                "    ],\n" +
+                "    \"imageManagerActionName\": \"listimage\",\n" +
+                "    \"imageManagerListPath\": \"/ueditor/jsp/upload/image/\",\n" +
+                "    \"imageManagerListSize\": 20, \n" +
+                "    \"imageManagerUrlPrefix\": \"\", \n" +
+                "    \"imageManagerInsertAlign\": \"none\", \n" +
+                "    \"imageManagerAllowFiles\": [\".png\", \".jpg\", \".jpeg\", \".gif\", \".bmp\"],\n" +
+                "    \"fileManagerActionName\": \"listfile\", \n" +
+                "    \"fileManagerListPath\": \"/ueditor/jsp/upload/file/\",\n" +
+                "    \"fileManagerUrlPrefix\": \"\",\n" +
+                "    \"fileManagerListSize\": 20,\n" +
+                "    \"fileManagerAllowFiles\": [\n" +
+                "        \".png\", \".jpg\", \".jpeg\", \".gif\", \".bmp\",\n" +
+                "        \".flv\", \".swf\", \".mkv\", \".avi\", \".rm\", \".rmvb\", \".mpeg\", \".mpg\",\n" +
+                "        \".ogg\", \".ogv\", \".mov\", \".wmv\", \".mp4\", \".webm\", \".mp3\", \".wav\", \".mid\",\n" +
+                "        \".rar\", \".zip\", \".tar\", \".gz\", \".7z\", \".bz2\", \".cab\", \".iso\",\n" +
+                "        \".doc\", \".docx\", \".xls\", \".xlsx\", \".ppt\", \".pptx\", \".pdf\", \".txt\", \".md\", \".xml\"\n" +
+                "    ]\n" +
+                "\n" +
+                "}";
+
+    public String getState() {
+        return state;
+    }
+
+    public void setState(String state) {
+        this.state = state;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getOriginal() {
+        return original;
+    }
+
+    public void setOriginal(String original) {
+        this.original = original;
+    }
+}

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/InvestigateTableServiceImpl.java

@@ -66,8 +66,8 @@ public class InvestigateTableServiceImpl implements IInvestigateTableService {
         //新增考察配置与考察主表关联
         //insertInvestigateDispositionTable(investigateTable);
         List<InvestigateUser> investigateUserList = investigateTable.getInvestigateUserList();
-        int i = investigateTableMapper.insertInvestigateTable(investigateTable);
         investigateTable.setCipher(getCode(4));
+        int i = investigateTableMapper.insertInvestigateTable(investigateTable);
         if (investigateUserList != null) {
             for (InvestigateUser investigateUser : investigateUserList) {
                 investigateUser.setInvestigateId(investigateTable.getInvestigateTableId());

+ 36 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UploadService.java

@@ -0,0 +1,36 @@
+package com.ruoyi.system.service.impl;
+
+import com.ruoyi.common.config.RuoYiConfig;
+import com.ruoyi.system.domain.Ueditor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+import java.io.IOException;
+
+/**
+ * @Author: tjf
+ * @Date: 2023/10/13 11:26
+ * @Describe:
+ */
+@Service
+public class UploadService {
+
+
+    public Ueditor uploadPicForUeditor(MultipartFile file) {
+        Ueditor ueditor = new Ueditor();
+        ueditor.setState(Ueditor.ACTION_SUCCESS);
+        try {
+            //上传图片服务器后返回的地址
+            String s = RuoYiConfig.getUploadPath();
+            ueditor.setTitle(file.getName());
+            ueditor.setOriginal(file.getOriginalFilename());
+            ueditor.setUrl(s);
+            return ueditor;
+        } catch (Exception e) {
+            ueditor.setState(Ueditor.ACTION_FAIL);
+            e.printStackTrace();
+        }
+        return ueditor;
+    }
+
+}