From 9bc2d2981b540aa291cfecde5d33615df56a078b Mon Sep 17 00:00:00 2001 From: 疯狂的狮子li <15040126243@163.com> Date: 星期五, 22 七月 2022 09:59:19 +0800 Subject: [PATCH] update springboot 2.7.1 => 2.7.2 update hutool 5.8.3 => 5.8.4 update okhttp 4.9.1 => 4.10.0 update lock4j 2.2.1 => 2.2.2 update aws-java-sdk-s3 1.12.248 => 1.12.264 修复依赖安全漏洞 update aliyun.sms 2.0.9 => 2.0.16 update tencent.sms 3.1.537 => 3.1.555 update guava 30.0-jre => 31.1-jre --- ruoyi-demo/src/main/java/com/ruoyi/demo/controller/TestBatchController.java | 75 ++++++++++++++++++++++++++----------- 1 files changed, 53 insertions(+), 22 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 f3a7f6d..caed975 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 @@ -2,13 +2,10 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.R; import com.ruoyi.demo.domain.TestDemo; -import com.ruoyi.demo.service.ITestDemoService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; +import com.ruoyi.demo.mapper.TestDemoMapper; import lombok.RequiredArgsConstructor; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -23,37 +20,71 @@ * @author Lion Li * @date 2021-05-30 */ -@Api(value = "娴嬭瘯鎵归噺鏂规硶", tags = {"娴嬭瘯鎵归噺鏂规硶"}) -@RequiredArgsConstructor(onConstructor_ = @Autowired) +@RequiredArgsConstructor @RestController @RequestMapping("/demo/batch") public class TestBatchController extends BaseController { - private final ITestDemoService iTestDemoService; + /** + * 涓轰簡渚夸簬娴嬭瘯 鐩存帴寮曞叆mapper + */ + private final TestDemoMapper testDemoMapper; /** * 鏂板鎵归噺鏂规硶 鍙畬缇庢浛浠� saveBatch 绉掔骇鎻掑叆涓婁竾鏁版嵁 (瀵筸ysql璐熻嵎杈冨ぇ) + * <p> + * 3.5.0 鐗堟湰 澧炲姞 rewriteBatchedStatements=true 鎵瑰鐞嗗弬鏁� 浣� MP 鍘熺敓鎵瑰鐞嗗彲浠ヨ揪鍒板悓鏍风殑閫熷害 */ - @ApiOperation(value = "鏂板鎵归噺鏂规硶") - @PostMapping() -// @DataSource(DataSourceType.SLAVE) - public AjaxResult<Void> add() { - List<TestDemo> list = new ArrayList<>(); - for (int i = 0; i < 1000; i++) { - list.add(new TestDemo().setOrderNum(-1L).setTestKey("鎵归噺鏂板").setValue("娴嬭瘯鏂板")); - } - return toAjax(iTestDemoService.saveAll(list) ? 1 : 0); + @PostMapping("/add") +// @DS("slave") + public R<Void> add() { + List<TestDemo> list = new ArrayList<>(); + for (int i = 0; i < 1000; i++) { + TestDemo testDemo = new TestDemo(); + testDemo.setOrderNum(-1); + testDemo.setTestKey("鎵归噺鏂板"); + testDemo.setValue("娴嬭瘯鏂板"); + list.add(testDemo); + } + return toAjax(testDemoMapper.insertBatch(list) ? 1 : 0); + } + + /** + * 鏂板鎴栨洿鏂� 鍙畬缇庢浛浠� saveOrUpdateBatch 楂樻�ц兘 + * <p> + * 3.5.0 鐗堟湰 澧炲姞 rewriteBatchedStatements=true 鎵瑰鐞嗗弬鏁� 浣� MP 鍘熺敓鎵瑰鐞嗗彲浠ヨ揪鍒板悓鏍风殑閫熷害 + */ + @PostMapping("/addOrUpdate") +// @DS("slave") + public R<Void> addOrUpdate() { + List<TestDemo> list = new ArrayList<>(); + for (int i = 0; i < 1000; i++) { + TestDemo testDemo = new TestDemo(); + testDemo.setOrderNum(-1); + testDemo.setTestKey("鎵归噺鏂板"); + testDemo.setValue("娴嬭瘯鏂板"); + list.add(testDemo); + } + testDemoMapper.insertBatch(list); + for (int i = 0; i < list.size(); i++) { + TestDemo testDemo = list.get(i); + testDemo.setTestKey("鎵归噺鏂板鎴栦慨鏀�"); + testDemo.setValue("鎵归噺鏂板鎴栦慨鏀�"); + if (i % 2 == 0) { + testDemo.setId(null); + } + } + return toAjax(testDemoMapper.insertOrUpdateBatch(list) ? 1 : 0); } /** * 鍒犻櫎鎵归噺鏂规硶 */ - @ApiOperation(value = "鍒犻櫎鎵归噺鏂规硶") @DeleteMapping() -// @DataSource(DataSourceType.SLAVE) - public AjaxResult<Void> remove() { - return toAjax(iTestDemoService.remove(new LambdaQueryWrapper<TestDemo>() - .eq(TestDemo::getOrderNum, -1L)) ? 1 : 0); +// @DS("slave") + public R<Void> remove() { + return toAjax(testDemoMapper.delete(new LambdaQueryWrapper<TestDemo>() + .eq(TestDemo::getOrderNum, -1L))); } } -- Gitblit v1.9.3