1、讲师添加
1) 创建时间和修改时间字段使用自动填充方式
方法见:
https://blog.csdn.net/Sky_rabbit94/article/details/115417219?spm=1001.2014.3001.5501
2)编写Controller,传入一个eduTeacher对象
//添加讲师接口的方法
@PostMapping("addTeacher")
public R addTeacher(@RequestBody EduTeacher eduTeacher) {
boolean save = teacherService.save(eduTeacher);
if(save) {
return R.ok();
} else {
return R.error();
}
}
2、讲师修改功能
1)根据讲师id进行查询:
//根据讲师id进行查询
@GetMapping("getTeacher/{id}")
public R getTeacher(@PathVariable String id) {
EduTeacher eduTeacher = teacherService.getById(id);
return R.ok().data("teacher",eduTeacher);
}
2)讲师修改,也是根据id
//讲师修改功能
@PostMapping("updateTeacher")
public R updateTeacher(@RequestBody EduTeacher eduTeacher) {
boolean flag = teacherService.updateById(eduTeacher);
if(flag) {
return R.ok();
} else {
return R.error();
}
}