一、返回操作是否成功

1、删除业务逻辑

TeacherServiceImpl

  1. @Override
  2. public boolean removeById(Serializable id) {
  3. Integer result = baseMapper.deleteById(id);
  4. return null != result && result > 0;
  5. }

TeacherAdminController

  1. @ApiOperation(value = "根据ID删除讲师")
  2. @DeleteMapping("{id}")
  3. public R removeById(
  4. @ApiParam(name = "id", value = "讲师ID", required = true)
  5. @PathVariable String id){
  6. boolean result = teacherService.removeById(id);
  7. if(result){
  8. return R.ok();
  9. }else{
  10. return R.error().message("删除失败");
  11. }
  12. }

2、前端

在catch中处理错误信息