From f75ad39bbd4aae4c5e84afd690601337fc0e2c99 Mon Sep 17 00:00:00 2001 From: Alan <3052806735@qq.com> Date: Tue, 27 Aug 2024 16:55:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E9=80=81=E6=B6=88=E6=81=AF=EF=BC=8C?= =?UTF-8?q?=E4=B8=80=E6=AC=A1=E6=80=A7=E6=9C=80=E5=A4=9A=E5=8F=AA=E8=83=BD?= =?UTF-8?q?=E5=9C=A8=E4=B8=80=E4=B8=AA=E8=AF=BE=E7=A8=8B=E4=B8=8B=E5=8F=91?= =?UTF-8?q?=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/teaching/backend/common/ErrorCode.java | 1 + .../backend/service/impl/message/MessagesServiceImpl.java | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/main/java/com/teaching/backend/common/ErrorCode.java b/src/main/java/com/teaching/backend/common/ErrorCode.java index 9679c72..808b0e5 100644 --- a/src/main/java/com/teaching/backend/common/ErrorCode.java +++ b/src/main/java/com/teaching/backend/common/ErrorCode.java @@ -33,6 +33,7 @@ public enum ErrorCode { CONTENT_EXISTS(41000, "内容存在"), STUDENT_ROLE_CANT_MULTIPLESEND(41001, "学生用户不能群发,只能单发"), LEAST_ONE_USER(41002, "最少选择一个用户"), + MOST_ONE_COURSE(41003, "您一次性最多只能在一个课程下发消息!"), KNOWS_EXISTS(41001, "存在关联的知识点"), ADD_RELATION_FAILED(41002, "添加关系失败"), diff --git a/src/main/java/com/teaching/backend/service/impl/message/MessagesServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/message/MessagesServiceImpl.java index 6b7b2c4..7d1755e 100644 --- a/src/main/java/com/teaching/backend/service/impl/message/MessagesServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/message/MessagesServiceImpl.java @@ -59,6 +59,13 @@ public class MessagesServiceImpl extends ServiceImpl courseIds = Arrays.stream(sysMessageDTO.getCourseId().split(",")) + .map(String::valueOf) + .collect(Collectors.toList()); + if (courseIds.size()>1){ + throw new BusinessException(ErrorCode.MOST_ONE_COURSE); + } + // 4.判断是什么用户,只有教师可以群发,学生只能单发 String roleId = umsUserMapper.selectOne(new LambdaQueryWrapper<>(UmsUser.class) .eq(UmsUser::getId, sysMessageDTO.getSenderId())).getRoleId();