From 8f6484e47085fde953e4e7c725da6fa56228322b Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期三, 12 一月 2022 21:22:26 +0800
Subject: [PATCH] [重磅更新] 重写项目整体结构 数据处理下沉至 Mapper 符合 MVC 规范 减少循环依赖

---
 ruoyi-demo/src/main/java/com/ruoyi/demo/controller/TestBatchController.java |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/TestBatchController.java b/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/TestBatchController.java
index 54cd448..53a872d 100644
--- a/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/TestBatchController.java
+++ b/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/TestBatchController.java
@@ -4,7 +4,7 @@
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.demo.domain.TestDemo;
-import com.ruoyi.demo.service.ITestDemoService;
+import com.ruoyi.demo.mapper.TestDemoMapper;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
@@ -29,7 +29,10 @@
 @RequestMapping("/demo/batch")
 public class TestBatchController extends BaseController {
 
-    private final ITestDemoService iTestDemoService;
+    /**
+     * 涓轰簡渚夸簬娴嬭瘯 鐩存帴寮曞叆mapper
+     */
+    private final TestDemoMapper testDemoMapper;
 
     /**
      * 鏂板鎵归噺鏂规硶 鍙畬缇庢浛浠� saveBatch 绉掔骇鎻掑叆涓婁竾鏁版嵁 (瀵筸ysql璐熻嵎杈冨ぇ)
@@ -44,7 +47,7 @@
         for (int i = 0; i < 1000; i++) {
             list.add(new TestDemo().setOrderNum(-1L).setTestKey("鎵归噺鏂板").setValue("娴嬭瘯鏂板"));
         }
-        return toAjax(iTestDemoService.saveAll(list) ? 1 : 0);
+        return toAjax(testDemoMapper.insertBatch(list) ? 1 : 0);
     }
 
     /**
@@ -60,7 +63,7 @@
         for (int i = 0; i < 1000; i++) {
             list.add(new TestDemo().setOrderNum(-1L).setTestKey("鎵归噺鏂板").setValue("娴嬭瘯鏂板"));
         }
-        iTestDemoService.saveAll(list);
+        testDemoMapper.insertBatch(list);
         for (int i = 0; i < list.size(); i++) {
             TestDemo testDemo = list.get(i);
             testDemo.setTestKey("鎵归噺鏂板鎴栦慨鏀�").setValue("鎵归噺鏂板鎴栦慨鏀�");
@@ -68,7 +71,7 @@
                 testDemo.setId(null);
             }
         }
-        return toAjax(iTestDemoService.saveOrUpdateAll(list) ? 1 : 0);
+        return toAjax(testDemoMapper.insertOrUpdateBatch(list) ? 1 : 0);
     }
 
     /**
@@ -78,8 +81,8 @@
     @DeleteMapping()
 //	@DS("slave")
     public AjaxResult<Void> remove() {
-        return toAjax(iTestDemoService.remove(new LambdaQueryWrapper<TestDemo>()
-            .eq(TestDemo::getOrderNum, -1L)) ? 1 : 0);
+        return toAjax(testDemoMapper.delete(new LambdaQueryWrapper<TestDemo>()
+            .eq(TestDemo::getOrderNum, -1L)));
     }
 
 }

--
Gitblit v1.9.3