使用MyBatis-Plus 批量更新实现步骤如下:
1. 创建 Service, 实现 ServiceImpl
@Service
public class EmpService extends ServiceImpl<EmpMapper, Emp> {
}
ServiceImpl 是MyBatis-Plus 提供的,
2. 调用
调用时直接 即可
package ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
/**
* Created by caoshi at 21:47 2022-03-08
*/
@RestController
@RequestMapping("demo2")
public class DemoController2 {
@Autowired
private EmpService empService;
/**
* 批量更新
* @return
*/
@RequestMapping("/testBatchUpdate")
public String testBatchUpdate() {
List<Emp> empDoList = new ArrayList<>();
Emp emp1 = new Emp();
(7369);
("测试1");
Emp emp2 = new Emp();
(7499);
("测试2");
(emp1);
(emp2);
(empDoList);
return "success";
}
}