一、返回操作是否成功
1、删除业务逻辑
TeacherServiceImpl
@Override
public boolean removeById(Serializable id) {
Integer result = baseMapper.deleteById(id);
return null != result && result > 0;
}
TeacherAdminController
@ApiOperation(value = "根据ID删除讲师")
@DeleteMapping("{id}")
public R removeById(
@ApiParam(name = "id", value = "讲师ID", required = true)
@PathVariable String id){
boolean result = teacherService.removeById(id);
if(result){
return R.ok();
}else{
return R.error().message("删除失败");
}
}
2、前端
在catch中处理错误信息