观看mybatis-plus文档关于CRUD接口时发现的问题
一、之前写的更新一个对象的属性
@ApiOperation("更新学生")
@PostMapping("updateStu")
public R updateStu(@RequestBody Student student){
QueryWrapper<Student> wrapper = new QueryWrapper<>();
wrapper.eq("id",student.getId());
boolean flag = studentService.update(student, wrapper);
if (flag) {
return R.ok();
} else {
return R.error();
}
}
二、看完之后写的更新
@ApiOperation("更新学生")
@PostMapping("updateStu")
public R updateStu(@RequestBody Student student) {
boolean flag = studentService.updateById(student);
if (flag) {
return R.ok();
} else {
return R.error();
}
}
接口自带有updateById()方法