From 73fc90bf957d2cbcf392206e2937c0df059e7adb Mon Sep 17 00:00:00 2001
From: zhaowenxuan <chacca165@163.com>
Date: 星期一, 01 七月 2024 14:11:01 +0800
Subject: [PATCH] druid数据源配置

---
 src/main/java/com/example/controller/TestController.java |   59 +++++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 53 insertions(+), 6 deletions(-)

diff --git a/src/main/java/com/example/controller/TestController.java b/src/main/java/com/example/controller/TestController.java
index bee3641..397200f 100644
--- a/src/main/java/com/example/controller/TestController.java
+++ b/src/main/java/com/example/controller/TestController.java
@@ -1,12 +1,16 @@
 package com.example.controller;
 
 import com.example.utils.DictionaryUtil;
+import com.example.utils.DictionaryUtilNew;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.io.*;
+import java.util.List;
 
 /**
  * @Company: 瑗垮畨璺嘲绉戞妧鏈夐檺鍏徃
@@ -19,17 +23,33 @@
     private static final String LOG_PATH = "src/main/resources/log.log";
     @Autowired
     private DictionaryUtil dictionaryUtil;
+    @Autowired
+    private DictionaryUtilNew dictionaryUtilNew;
+
+    /**
+     * 鍏ㄩ儴瀛楀吀鍚屾
+     * @return
+     */
     @GetMapping("exec")
     public String exce(){
+        // 灏嗘枃浠跺唴瀹硅缃负绌�
+        FileWriter fileWriter = null;
         try {
-            dictionaryUtil.exec1();
-            return "鎵ц鎴愬姛";
-        } catch (IOException e) {
-            e.printStackTrace();
-            return e.getMessage();
-        }
+            fileWriter = new FileWriter(LOG_PATH);
+            fileWriter.write("");
+            fileWriter.close();
+        } catch (IOException ignored) {}
+        new Thread(()->{
+            // dictionaryUtil.exec1();
+            dictionaryUtilNew.exec1();
+        }).start();
+        return "宸叉彁浜ゆ墽琛�";
     }
 
+    /**
+     * 鏄剧ず鏃ュ織
+     * @return
+     */
     @GetMapping("/show")
     public String showLog() {
         StringBuilder logContent = new StringBuilder();
@@ -45,6 +65,10 @@
         }
     }
 
+    /**
+     * 娓呴櫎鏃ュ織
+     * @return
+     */
     @GetMapping("/clear")
     public String cleanLog() {
         try {
@@ -58,4 +82,27 @@
             return "Failed to clear log content.";
         }
     }
+
+    /**
+     * 鎵嬪姩鍚屾
+     * @param methods 鍚屾鐨勫瓧鍏稿悕
+     * @param type 鏄惁鍦ㄥ悓姝ュ墠娓呴櫎鏃ュ織 榛樿鍚�
+     * @return
+     */
+    @PostMapping("exec")
+    public String execPost(@RequestParam("methods")List<String > methods,@RequestParam(value = "type",required = false,defaultValue = "false")Boolean type){
+        if (type){
+            FileWriter fileWriter = null;
+            try {
+                fileWriter = new FileWriter(LOG_PATH);
+                fileWriter.write("");
+                fileWriter.close();
+            } catch (IOException ignored) {}
+        }
+        new Thread(()->{
+            //                dictionaryUtil.exec1();
+            dictionaryUtilNew.execMethods(methods);
+        }).start();
+        return "宸叉彁浜ゆ墽琛�";
+    }
 }

--
Gitblit v1.8.0