From 814a05234d021177ffaaa81e2e1fc6b39462fb89 Mon Sep 17 00:00:00 2001 From: Alan <3052806735@qq.com> Date: Sat, 24 Aug 2024 10:32:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E8=AF=BE=E7=A8=8B=E6=80=BB?= =?UTF-8?q?=E7=9B=AE=E6=A0=87=E6=97=B6=E7=9A=84=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/teaching/backend/common/ErrorCode.java | 3 ++- .../service/impl/courses/ObjectiveContentsServiceImpl.java | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/teaching/backend/common/ErrorCode.java b/src/main/java/com/teaching/backend/common/ErrorCode.java index da1ebfd..3db20f0 100644 --- a/src/main/java/com/teaching/backend/common/ErrorCode.java +++ b/src/main/java/com/teaching/backend/common/ErrorCode.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, "无权限"), diff --git a/src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentsServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentsServiceImpl.java index 98e90de..6d551a9 100644 --- a/src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentsServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentsServiceImpl.java @@ -48,6 +48,11 @@ public class ObjectiveContentsServiceImpl extends ServiceImpl 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 ? "删除成功!" : "删除失败!"; }