mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-24 07:19:46 +08:00
saveAll支持有id则更新和无id则插入
This commit is contained in:
@ -39,8 +39,13 @@ public class TestBatchController extends BaseController {
|
||||
// @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("测试新增"));
|
||||
for (int i = 0; i < 10; i++) {
|
||||
TestDemo testDemo = new TestDemo();
|
||||
if (i % 2 == 0) {
|
||||
list.add(testDemo.setId((long) i + 1).setTestKey("批量更新").setValue("批量更新"));
|
||||
} else {
|
||||
list.add(testDemo.setOrderNum(-1L).setTestKey("批量新增").setValue("测试新增"));
|
||||
}
|
||||
}
|
||||
return toAjax(iTestDemoService.saveAll(list) ? 1 : 0);
|
||||
}
|
||||
|
Reference in New Issue
Block a user