删除课程总目标时的判断

master
Alan 3 months ago
parent 5390751e57
commit 814a05234d
  1. 3
      src/main/java/com/teaching/backend/common/ErrorCode.java
  2. 5
      src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentsServiceImpl.java

@ -22,7 +22,8 @@ public enum ErrorCode {
INVALID_ROLE(400010, "角色不存在"),
MESSAGE_NO_READ(400011, "消息未读,禁止删除!"),
MESSAGE_NO_EXIT(400012, "消息不存在!"),
CONTENT_HAS_NO_KNOWS(400013, "该课程目标暂未关联知识点!"),
TOTOAL_OBJECTIVE_CANT_DELETE(400013, "课程总目标内容禁止删除!"),
NOT_LOGIN_ERROR(40100, "未登录"),
NO_AUTH_ERROR(40101, "无权限"),

@ -48,6 +48,11 @@ public class ObjectiveContentsServiceImpl extends ServiceImpl<ObjectiveContentsM
if(count > CourseCode.KNOWS_EXIT.getValue()){
throw new BusinessException(ErrorCode.KNOWS_EXIT);
}
String objectiveId = objectiveContentsMapper.selectById(id).getObjectiveId();
Integer type = courseObjectivesMapper.selectById(objectiveId).getType();
if (type == TOTAL_OBJECTIVE_TYPE.getValue()){
throw new BusinessException(ErrorCode.TOTOAL_OBJECTIVE_CANT_DELETE);
}
int delete = objectiveContentsMapper.deleteById(id);
return delete > 0 ? "删除成功!" : "删除失败!";
}

Loading…
Cancel
Save