From 2ff36d81a13913c92b2cf52c2df29a35c472330a Mon Sep 17 00:00:00 2001 From: 疯狂的狮子Li <15040126243@163.com> Date: 星期四, 03 三月 2022 22:55:49 +0800 Subject: [PATCH] update 优化 防重 与 限流 功能支持国际化消息返回 --- ruoyi-demo/src/main/java/com/ruoyi/demo/controller/TestBatchController.java | 24 ++++++++++++++++-------- 1 files changed, 16 insertions(+), 8 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 39cf3eb..1bb9d9f 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,7 +2,7 @@ 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.mapper.TestDemoMapper; import io.swagger.annotations.Api; @@ -41,10 +41,14 @@ @ApiOperation(value = "鏂板鎵归噺鏂规硶") @PostMapping("/add") // @DS("slave") - public AjaxResult<Void> add() { + public R<Void> add() { List<TestDemo> list = new ArrayList<>(); for (int i = 0; i < 1000; i++) { - list.add(new TestDemo().setOrderNum(-1L).setTestKey("鎵归噺鏂板").setValue("娴嬭瘯鏂板")); + TestDemo testDemo = new TestDemo(); + testDemo.setOrderNum(-1L); + testDemo.setTestKey("鎵归噺鏂板"); + testDemo.setValue("娴嬭瘯鏂板"); + list.add(testDemo); } return toAjax(testDemoMapper.insertBatch(list) ? 1 : 0); } @@ -57,15 +61,19 @@ @ApiOperation(value = "鏂板鎴栨洿鏂版壒閲忔柟娉�") @PostMapping("/addOrUpdate") // @DS("slave") - public AjaxResult<Void> addOrUpdate() { + public R<Void> addOrUpdate() { List<TestDemo> list = new ArrayList<>(); for (int i = 0; i < 1000; i++) { - list.add(new TestDemo().setOrderNum(-1L).setTestKey("鎵归噺鏂板").setValue("娴嬭瘯鏂板")); - } + TestDemo testDemo = new TestDemo(); + testDemo.setOrderNum(-1L); + 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("鎵归噺鏂板鎴栦慨鏀�").setValue("鎵归噺鏂板鎴栦慨鏀�"); + testDemo.setTestKey("鎵归噺鏂板鎴栦慨鏀�"); + testDemo.setValue("鎵归噺鏂板鎴栦慨鏀�"); if (i % 2 == 0) { testDemo.setId(null); } @@ -79,7 +87,7 @@ @ApiOperation(value = "鍒犻櫎鎵归噺鏂规硶") @DeleteMapping() // @DS("slave") - public AjaxResult<Void> remove() { + public R<Void> remove() { return toAjax(testDemoMapper.delete(new LambdaQueryWrapper<TestDemo>() .eq(TestDemo::getOrderNum, -1L))); } -- Gitblit v1.9.3