From d83de6f4bd6ad2676faaf30d5f7e72b766e2b060 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Mon, 17 Apr 2023 14:03:23 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BC=9A=E8=AF=9D=E7=BE=A4=E7=BB=84?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E9=80=9A=E7=9F=A5=E4=BA=8B=E4=BB=B6=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cbtc/ATS/operation/Operation.java | 54 ++++++++ .../rtss/simulation/cbtc/Simulation.java | 4 + .../cbtc/conversation/ConversationGroup.java | 32 ++++- .../ConversationGroupHandlerService.java | 124 ++++++++++++++++-- .../ConversationGroupOperateHandler.java | 27 ++++ .../vo/ConversationGroupSocketMessageVO.java | 108 +++++++++++++++ .../cbtc/data/vo/ConversationGroupVO.java | 19 +++ ...imulationConversationGroupCreateEvent.java | 20 +++ ...ulationConversationGroupDissolveEvent.java | 20 +++ .../SimulationConversationGroupExitEvent.java | 27 ++++ ...imulationConversationGroupInviteEvent.java | 35 +++++ ...imulationConversationGroupRemoveEvent.java | 30 +++++ ...imulationConversationGroupUpdateEvent.java | 20 +++ 13 files changed, 502 insertions(+), 18 deletions(-) create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/ConversationGroupSocketMessageVO.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/event/conversation/SimulationConversationGroupCreateEvent.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/event/conversation/SimulationConversationGroupDissolveEvent.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/event/conversation/SimulationConversationGroupExitEvent.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/event/conversation/SimulationConversationGroupInviteEvent.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/event/conversation/SimulationConversationGroupRemoveEvent.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/event/conversation/SimulationConversationGroupUpdateEvent.java diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java index 7b8665270..99e36df7c 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java @@ -1578,6 +1578,60 @@ public class Operation { */ YJDDZH_VOICE_COMMAND(new Label[]{Label.CLIENT},true), + /** + * 会话群组创建 + */ + Conversation_Group_Create(new Label[]{Label.CLIENT}, true), + + /** + * 会话群组修改组名 + */ + Conversation_Group_Update_Name(new Label[]{Label.CLIENT}, true), + + /** + * 会话群组修改群主 + */ + Conversation_Group_Update_Leader(new Label[]{Label.CLIENT}, true), + + /** + * 会话群组邀请成员 + */ + Conversation_Group_Invite_Member(new Label[]{Label.CLIENT}, true), + + /** + * 会话群组移除成员 + */ + Conversation_Group_Remove_Member(new Label[]{Label.CLIENT}, true), + + /** + * 会话群组退出 + */ + Conversation_Group_Exit(new Label[]{Label.CLIENT}, true), + + /** + * 会话群组解散 + */ + Conversation_Group_Dissolve(new Label[]{Label.CLIENT}, true), + + /** + * 会话群组语音文件聊天 + */ + Conversation_Group_Audio_Chat(new Label[]{Label.CLIENT}, true), + + /** + * 会话群组文字聊天 + */ + Conversation_Group_Text_Chat(new Label[]{Label.CLIENT}, true), + + /** + * 会话群组语音文件聊天 + */ + Conversation_Group_Audio_Base64(new Label[]{Label.CLIENT}, true), + + /** + * 会话群组获取未读消息 + */ + Conversation_Group_Get_Unread_Message(new Label[]{Label.CLIENT}, true), //---------------------------- PSL ------------------------------ /** * PSL盘按下按钮 diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java b/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java index 40445661d..c3c6aa7e2 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java @@ -326,6 +326,10 @@ public class Simulation extends club.joylink.rtss.simulation.Simulation map) { this.simulationConversationGroupMap.putAll(map); Long groupId = map.keySet().stream().max(Comparator.comparing(Long::longValue)).orElse(0L); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/conversation/ConversationGroup.java b/src/main/java/club/joylink/rtss/simulation/cbtc/conversation/ConversationGroup.java index 4f8160ee8..58a55f787 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/conversation/ConversationGroup.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/conversation/ConversationGroup.java @@ -11,6 +11,7 @@ import org.springframework.util.CollectionUtils; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; @@ -30,8 +31,19 @@ public class ConversationGroup extends Chat { */ private String name; + /** + * 群主 + */ + private SimulationMember leader; + + /** + * 群消息列表 + */ private List messageList = new ArrayList<>(); + /** + * 消息主键 + */ private AtomicInteger messageId = new AtomicInteger(0); /** @@ -44,11 +56,11 @@ public class ConversationGroup extends Chat { this.id = info.getId(); this.name = info.getName(); setTime(simulation.getCorrectSystemTime()); - SimulationMember leader = null; - if (info.getLeaderId() != null) { - leader = simulation.getSimulationMemberById(info.getLeaderId()); - setCreator(leader); + if (info.getLeaderId() != null) { // 设置群主 + this.leader = simulation.getSimulationMemberById(info.getLeaderId()); + setCreator(this.leader); } + setTime(simulation.getCorrectSystemTime()); List memberList = null; if (!CollectionUtils.isEmpty(info.getMemberIds())) { memberList = info.getMemberIds().stream().distinct().map(simulation::getSimulationMemberById) @@ -60,6 +72,7 @@ public class ConversationGroup extends Chat { public ConversationGroup(Long id, String name, LocalDateTime time, SimulationMember leader, List simulationMembers){ this.id = id; this.name = name; + this.leader = leader; setTime(time); setCreator(leader); if (!CollectionUtils.isEmpty(simulationMembers)) { @@ -94,7 +107,7 @@ public class ConversationGroup extends Chat { public List getUnreadMessages(SimulationMember member) { ConversationMember conversationMember = getConversionMember(member); // 没有消息,不是本群人员 - if (CollectionUtils.isEmpty(getMessageList()) && !isCreator(member) && conversationMember != null) { + if (CollectionUtils.isEmpty(getMessageList()) && !isLeader(member) && conversationMember == null) { return List.of(); } return messageList.stream().filter(message -> { @@ -128,4 +141,13 @@ public class ConversationGroup extends Chat { getMemberList().add(conversationMember); } } + + /** + * 是否群主 + * @param member 成员 + * @return 结果 + */ + public boolean isLeader(SimulationMember member) { + return Objects.equals(member, this.leader); + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/conversation/ConversationGroupHandlerService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/conversation/ConversationGroupHandlerService.java index 40a11b91b..54b93c28f 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/conversation/ConversationGroupHandlerService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/conversation/ConversationGroupHandlerService.java @@ -5,6 +5,7 @@ import club.joylink.rtss.simulation.cbtc.GroupSimulationCache; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.data.vo.ConversationGroupMessageVO; import club.joylink.rtss.simulation.cbtc.data.vo.ConversationGroupVO; +import club.joylink.rtss.simulation.cbtc.event.conversation.*; import club.joylink.rtss.simulation.cbtc.exception.SimulationException; import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; import club.joylink.rtss.simulation.cbtc.member.SimulationMember; @@ -12,6 +13,8 @@ import club.joylink.rtss.vo.client.voice.VoiceRecognitionResult; import club.joylink.rtss.vo.client.voice.VoiceRecognitionVO; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.context.event.EventListener; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -32,10 +35,13 @@ public class ConversationGroupHandlerService { @Autowired private SimulationVoiceHandler simulationVoiceHandler; + @Autowired + private ApplicationEventPublisher applicationEventPublisher; + /** * 获取所有群组信息 - * @param group - * @return + * @param group 仿真ID + * @return 群组信息 */ public List getAllConversationsGroup(String group) { Simulation simulation = groupSimulationCache.getSimulationByGroup(group); @@ -60,8 +66,8 @@ public class ConversationGroupHandlerService { Long groupId = simulation.getMaxConversationGroupId(); conversationGroup = new ConversationGroup(groupId, name, simulation.getCorrectSystemTime(), member, simulationMembers); simulation.addConversationGroup(conversationGroup); - // 通知用户消息 TODO - + // 通知用户消息 + applicationEventPublisher.publishEvent(new SimulationConversationGroupCreateEvent(this, simulation, conversationGroup)); return new ConversationGroupVO(conversationGroup); } @@ -83,8 +89,8 @@ public class ConversationGroupHandlerService { return; } conversationGroup.setName(name); - // 通知其他用户群名变更 TODO - + // 通知其他用户群名变更 + applicationEventPublisher.publishEvent(new SimulationConversationGroupUpdateEvent(this, simulation, conversationGroup)); } /** @@ -103,8 +109,8 @@ public class ConversationGroupHandlerService { } // 设置群组 conversationGroup.setCreator(simulationMember); - // 发送通知消息 TODO - + // 发送通知消息 + applicationEventPublisher.publishEvent(new SimulationConversationGroupUpdateEvent(this, simulation, conversationGroup)); } /** @@ -125,8 +131,30 @@ public class ConversationGroupHandlerService { SimulationMember newMember = simulation.getSimulationMemberById(memberId); conversationGroup.addSimulationMember(newMember, simulation.getCorrectSystemTime()); }); - // 给新加入的用户发送消息 TODO + // 给新加入的用户发送消息 + applicationEventPublisher.publishEvent(new SimulationConversationGroupInviteEvent(this, simulation, conversationGroup, groupMemberIds, newMemberIds)); + } + /** + * 移除群组用户 + * @param simulation 仿真 + * @param member 用户 + * @param groupId 群组主键 + * @param memberIds 角色ID + */ + public void removeMemberConversationGroup(Simulation simulation, SimulationMember member, Long groupId, List memberIds) { + ConversationGroup conversationGroup = checkGroupIdAndReturn(simulation, member, groupId); + if (memberIds.contains(conversationGroup.getLeader().getId())) { + throw new SimulationException(SimulationExceptionType.Illegal_Argument, "群主不能移除"); + } + List removeSimulationMemberList = new ArrayList<>(memberIds.size()); + conversationGroup.getSimulationMemberList().stream().filter(m -> memberIds.contains(m.getId())) + .forEach(m -> { + removeSimulationMemberList.add(m); + conversationGroup.exit(m); + }); + // 给新加入的用户发送消息 + applicationEventPublisher.publishEvent(new SimulationConversationGroupRemoveEvent(this, simulation, conversationGroup, removeSimulationMemberList)); } /** @@ -144,8 +172,21 @@ public class ConversationGroupHandlerService { throw new SimulationException(SimulationExceptionType.Illegal_Argument, "请先变更群主"); } conversationGroup.exit(member); - // 发送退群消息 TODO + // 发送退群消息 + applicationEventPublisher.publishEvent(new SimulationConversationGroupExitEvent(this, simulation, conversationGroup, member)); + } + /** + * 解散群组 + * @param simulation 仿真 + * @param member 用户 + * @param groupId 群组主键 + */ + public void dissolveConversationGroup(Simulation simulation, SimulationMember member, Long groupId) { + ConversationGroup conversationGroup = checkGroupIdAndReturn(simulation, member, groupId); + simulation.removeConversionGroup(conversationGroup); + // 发送解散消息 + applicationEventPublisher.publishEvent(new SimulationConversationGroupDissolveEvent(this, simulation, conversationGroup)); } /** @@ -197,8 +238,7 @@ public class ConversationGroupHandlerService { public ConversationGroupMessageVO audioBase64(Simulation simulation, SimulationMember member, Long groupId, String fileBase64Str) { ConversationGroupMessage message = sendMessage(simulation, member, groupId, () -> { VoiceRecognitionVO vo = VoiceRecognitionVO.load(fileBase64Str); - VoiceRecognitionResult recognitionResult = iVoiceService.voiceRecognition(vo); - return recognitionResult; + return iVoiceService.voiceRecognition(vo); }); return new ConversationGroupMessageVO(message); } @@ -228,6 +268,62 @@ public class ConversationGroupHandlerService { return ConversationGroupMessageVO.convert2VO(messageList); } + /** + * 处理创建群组事件 + * @param event 事件信息 + */ + @EventListener + public void handleCreate(SimulationConversationGroupCreateEvent event) { + ConversationGroup conversationGroup = event.getConversationGroup(); + + } + + /** + * 处理更新群组信息事件 + * @param event 事件信息 + */ + @EventListener + public void handleUpdate(SimulationConversationGroupUpdateEvent event) { + + } + + /** + * 处理邀请成员事件 + * @param event 事件信息 + */ + @EventListener + public void handleInvite(SimulationConversationGroupInviteEvent event) { + + } + + /** + * 群组移除人员事件 + * + * @param event 事件信息 + */ + @EventListener + public void handleRemove(SimulationConversationGroupRemoveEvent event) { + + } + + /** + * 处理退出群组事件 + * @param event 事件信息 + */ + @EventListener + public void handleExit(SimulationConversationGroupExitEvent event) { + + } + + /** + * 解散群主事件 + * @param event 事件信息 + */ + @EventListener + public void handleDissolve(SimulationConversationGroupDissolveEvent event) { + + } + /** * 对群组操作时基础判断 * @@ -241,7 +337,7 @@ public class ConversationGroupHandlerService { if (conversationGroup == null) { throw new SimulationException(SimulationExceptionType.Illegal_Argument, "群组不存在"); } - if (member != null && !Objects.equals(member.getId(), conversationGroup.getCreator().getId())) { + if (member != null && !Objects.equals(member.getId(), conversationGroup.getLeader().getId())) { throw new SimulationException(SimulationExceptionType.Illegal_Argument, "您无操作权限"); } return conversationGroup; @@ -278,4 +374,6 @@ public class ConversationGroupHandlerService { return message; } + + } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/conversation/ConversationGroupOperateHandler.java b/src/main/java/club/joylink/rtss/simulation/cbtc/conversation/ConversationGroupOperateHandler.java index 31c50e638..62345183e 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/conversation/ConversationGroupOperateHandler.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/conversation/ConversationGroupOperateHandler.java @@ -1,6 +1,8 @@ package club.joylink.rtss.simulation.cbtc.conversation; +import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation; import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandler; +import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandlerMapping; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.data.vo.ConversationGroupMessageVO; import club.joylink.rtss.simulation.cbtc.data.vo.ConversationGroupVO; @@ -26,6 +28,7 @@ public class ConversationGroupOperateHandler { * @param name * @param memberIds */ + @OperateHandlerMapping(type = Operation.Type.Conversation_Group_Create) public ConversationGroupVO createConversationGroup(Simulation simulation, SimulationMember member, String name, List memberIds) { return conversationGroupManagerService.createConversationGroup(simulation, member, name, memberIds); } @@ -33,6 +36,7 @@ public class ConversationGroupOperateHandler { /** * 修改群组名称等基本信息 */ + @OperateHandlerMapping(type = Operation.Type.Conversation_Group_Update_Name) public void updateConversationGroup(Simulation simulation, SimulationMember member, Long groupId, String name) { conversationGroupManagerService.updateConversationGroup(simulation, member, groupId, name); } @@ -45,6 +49,7 @@ public class ConversationGroupOperateHandler { * @param groupId 群组ID * @param memberId 用户ID */ + @OperateHandlerMapping(type = Operation.Type.Conversation_Group_Update_Leader) public void setConversationGroupLeader(Simulation simulation, SimulationMember member, Long groupId, String memberId) { conversationGroupManagerService.setConversationGroupLeader(simulation, member, groupId, memberId); } @@ -52,20 +57,39 @@ public class ConversationGroupOperateHandler { /** * 邀请角色进群组 */ + @OperateHandlerMapping(type = Operation.Type.Conversation_Group_Invite_Member) public void inviteMembersInConversationGroup(Simulation simulation, SimulationMember member, Long groupId, List memberIds) { conversationGroupManagerService.inviteMembersInConversationGroup(simulation, member, groupId, memberIds); } + /** + * 踢人 + */ + @OperateHandlerMapping(type = Operation.Type.Conversation_Group_Remove_Member) + public void removeMemberConversationGroup(Simulation simulation, SimulationMember member, Long groupId, List memberIds) { + conversationGroupManagerService.removeMemberConversationGroup(simulation, member, groupId, memberIds); + } + /** * 退出群组信息 */ + @OperateHandlerMapping(type = Operation.Type.Conversation_Group_Exit) public void exitConversationGroup(Simulation simulation, SimulationMember member, Long groupId) { conversationGroupManagerService.exitConversationGroup(simulation, member, groupId); } + /** + * 解散群组 + */ + @OperateHandlerMapping(type = Operation.Type.Conversation_Group_Dissolve) + public void dissolveConversationGroup(Simulation simulation, SimulationMember member, Long groupId) { + conversationGroupManagerService.dissolveConversationGroup(simulation, member, groupId); + } + /** * 发送语音信息 */ + @OperateHandlerMapping(type = Operation.Type.Conversation_Group_Audio_Chat) public ConversationGroupMessageVO audioChat(Simulation simulation, SimulationMember member, Long groupId, String audioPath, String content) { return conversationGroupManagerService.audioChat(simulation, member, groupId, audioPath, content); } @@ -73,6 +97,7 @@ public class ConversationGroupOperateHandler { /** * 发送文字信息 */ + @OperateHandlerMapping(type = Operation.Type.Conversation_Group_Text_Chat) public ConversationGroupMessageVO textChat(Simulation simulation, SimulationMember member, Long groupId, String content) { return conversationGroupManagerService.textChat(simulation, member, groupId, content); } @@ -80,6 +105,7 @@ public class ConversationGroupOperateHandler { /** * 发送Base64音频文件 */ + @OperateHandlerMapping(type = Operation.Type.Conversation_Group_Audio_Base64) public ConversationGroupMessageVO audioBase64(Simulation simulation, SimulationMember member, Long groupId, String fileBase64Str) { return conversationGroupManagerService.audioBase64(simulation, member, groupId, fileBase64Str); } @@ -87,6 +113,7 @@ public class ConversationGroupOperateHandler { /** * 阅读群组信息 */ + @OperateHandlerMapping(type = Operation.Type.Conversation_Group_Get_Unread_Message) public List readConversationGroup(Simulation simulation, SimulationMember member, Long groupId) { return conversationGroupManagerService.readConversationGroup(simulation, member, groupId); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/ConversationGroupSocketMessageVO.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/ConversationGroupSocketMessageVO.java new file mode 100644 index 000000000..3dfcfbf2d --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/ConversationGroupSocketMessageVO.java @@ -0,0 +1,108 @@ +package club.joylink.rtss.simulation.cbtc.data.vo; + +import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.conversation.Conversation; +import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroup; +import club.joylink.rtss.simulation.cbtc.conversation.ConversationMessage; +import club.joylink.rtss.simulation.cbtc.discriminate.ParamExtractResult; +import club.joylink.rtss.simulation.cbtc.member.SimulationMember; +import lombok.Getter; + +import java.util.List; +import java.util.stream.Collectors; + +@Getter +public class ConversationGroupSocketMessageVO { + + private Long id; + + /** + * 群组名称 + */ + private String name; + + /** + * 创建人 + */ + private String creatorId; + + /** + * 群主 + */ + private String leaderId; + + /** + * 成员列表 + */ + private List memberList; + + /** + * 消息体 + */ + private ConversationGroupMessageVO message; + + /** + * 消息类型 + */ + private MessageType messageType; + + public enum MessageType { + /** + * 会话组创建 + */ + CREATE { + @Override + public ConversationGroupSocketMessageVO generateMessageVO(ConversationGroup group, ConversationGroupMessageVO message) { + ConversationGroupSocketMessageVO messageVO = new ConversationGroupSocketMessageVO(); + messageVO.id = group.getId(); + messageVO.name = group.getName(); + messageVO.creatorId = group.getCreator() != null ? group.getCreator().getId() : null; + messageVO.leaderId = group.getLeader() != null ? group.getLeader().getId() : null; + messageVO.memberList = group.getMemberList().stream().map(ConversationMemberVO::new).collect(Collectors.toList()); + messageVO.messageType = MessageType.CREATE; + return messageVO; + } + }, + /** + * 会话组更新 + */ + UPDATE { + @Override + public ConversationGroupSocketMessageVO generateMessageVO(ConversationGroup group, ConversationGroupMessageVO message) { + ConversationGroupSocketMessageVO messageVO = new ConversationGroupSocketMessageVO(); + messageVO.id = group.getId(); + messageVO.name = group.getName(); + messageVO.leaderId = group.getLeader() != null ? group.getLeader().getId() : null; + messageVO.memberList = group.getMemberList().stream().map(ConversationMemberVO::new).collect(Collectors.toList()); + messageVO.messageType = MessageType.UPDATE; + return messageVO; + } + }, + + + /** 会话组邀请 */ + INVITE { + @Override + public ConversationGroupSocketMessageVO generateMessageVO(ConversationGroup group, ConversationGroupMessageVO message) { + return null; + } + }, + /** 成员发送消息 */ + MESSAGE { + @Override + public ConversationGroupSocketMessageVO generateMessageVO(ConversationGroup group, ConversationGroupMessageVO message) { + return null; + } + }, + /** 会话结束 */ + EXIT { + @Override + public ConversationGroupSocketMessageVO generateMessageVO(ConversationGroup group, ConversationGroupMessageVO message) { + return null; + } + }; + + public abstract ConversationGroupSocketMessageVO generateMessageVO(ConversationGroup group, ConversationGroupMessageVO message); + } + +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/ConversationGroupVO.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/ConversationGroupVO.java index 4503cf041..25a32d4a6 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/ConversationGroupVO.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/ConversationGroupVO.java @@ -2,6 +2,7 @@ package club.joylink.rtss.simulation.cbtc.data.vo; import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroup; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; import org.springframework.util.CollectionUtils; @@ -10,10 +11,13 @@ import java.util.List; @Getter @Setter +@NoArgsConstructor public class ConversationGroupVO { private Long id; + private String name; + private String creatorId; private List memberList; @@ -22,6 +26,7 @@ public class ConversationGroupVO { public ConversationGroupVO(ConversationGroup conversation) { this.id = conversation.getId(); + this.name = conversation.getName(); if (conversation.getCreator() != null) { this.creatorId = conversation.getCreator().getId(); } @@ -29,6 +34,20 @@ public class ConversationGroupVO { this.messageList = ConversationGroupMessageVO.convert2VO(conversation.getMessageList()); } + + /** + * 生成不带消息的VO对象 + * @param conversation + */ + public void generateConversationGroupVOWithOutMessage(ConversationGroup conversation) { + this.id = conversation.getId(); + this.name = conversation.getName(); + if (conversation.getCreator() != null) { + this.creatorId = conversation.getCreator().getId(); + } + this.memberList = ConversationMemberVO.convert2VOList(conversation.getMemberList()); + } + public static List convert2VOList(List list) { List voList = new ArrayList<>(); if (!CollectionUtils.isEmpty(list)) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/event/conversation/SimulationConversationGroupCreateEvent.java b/src/main/java/club/joylink/rtss/simulation/cbtc/event/conversation/SimulationConversationGroupCreateEvent.java new file mode 100644 index 000000000..fe19d1123 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/event/conversation/SimulationConversationGroupCreateEvent.java @@ -0,0 +1,20 @@ +package club.joylink.rtss.simulation.cbtc.event.conversation; + +import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroup; +import club.joylink.rtss.simulation.cbtc.event.AbstractSimulationEvent; +import lombok.Getter; + +/** + * 群组创建成功 + */ +@Getter +public class SimulationConversationGroupCreateEvent extends AbstractSimulationEvent { + + private ConversationGroup conversationGroup; + + public SimulationConversationGroupCreateEvent(Object source, Simulation simulation, ConversationGroup conversationGroup) { + super(source, simulation); + this.conversationGroup = conversationGroup; + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/event/conversation/SimulationConversationGroupDissolveEvent.java b/src/main/java/club/joylink/rtss/simulation/cbtc/event/conversation/SimulationConversationGroupDissolveEvent.java new file mode 100644 index 000000000..3e6d0f556 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/event/conversation/SimulationConversationGroupDissolveEvent.java @@ -0,0 +1,20 @@ +package club.joylink.rtss.simulation.cbtc.event.conversation; + +import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroup; +import club.joylink.rtss.simulation.cbtc.event.AbstractSimulationEvent; +import lombok.Getter; + +/** + * 群组退群事件 + */ +@Getter +public class SimulationConversationGroupDissolveEvent extends AbstractSimulationEvent { + + private ConversationGroup conversationGroup; + + public SimulationConversationGroupDissolveEvent(Object source, Simulation simulation, ConversationGroup conversationGroup) { + super(source, simulation); + this.conversationGroup = conversationGroup; + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/event/conversation/SimulationConversationGroupExitEvent.java b/src/main/java/club/joylink/rtss/simulation/cbtc/event/conversation/SimulationConversationGroupExitEvent.java new file mode 100644 index 000000000..3fe0c4351 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/event/conversation/SimulationConversationGroupExitEvent.java @@ -0,0 +1,27 @@ +package club.joylink.rtss.simulation.cbtc.event.conversation; + +import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroup; +import club.joylink.rtss.simulation.cbtc.event.AbstractSimulationEvent; +import club.joylink.rtss.simulation.cbtc.member.SimulationMember; +import lombok.Getter; + +/** + * 群组退群事件 + */ +@Getter +public class SimulationConversationGroupExitEvent extends AbstractSimulationEvent { + + private ConversationGroup conversationGroup; + + /** + * 退群用户 + */ + private SimulationMember member; + + public SimulationConversationGroupExitEvent(Object source, Simulation simulation, ConversationGroup conversationGroup, SimulationMember member) { + super(source, simulation); + this.conversationGroup = conversationGroup; + this.member = member; + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/event/conversation/SimulationConversationGroupInviteEvent.java b/src/main/java/club/joylink/rtss/simulation/cbtc/event/conversation/SimulationConversationGroupInviteEvent.java new file mode 100644 index 000000000..2fa1c191e --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/event/conversation/SimulationConversationGroupInviteEvent.java @@ -0,0 +1,35 @@ +package club.joylink.rtss.simulation.cbtc.event.conversation; + +import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroup; +import club.joylink.rtss.simulation.cbtc.event.AbstractSimulationEvent; +import lombok.Getter; + +import java.util.List; + +/** + * 群组信息变更事件 + */ +@Getter +public class SimulationConversationGroupInviteEvent extends AbstractSimulationEvent { + + private ConversationGroup conversationGroup; + + /** + * 原有群组组员 + */ + private List groupMemberIds; + + /** + * 新加入的组员 + */ + private List newGroupMemberIds; + + public SimulationConversationGroupInviteEvent(Object source, Simulation simulation, ConversationGroup conversationGroup + , List groupMemberIds, List newGroupMemberIds) { + super(source, simulation); + this.conversationGroup = conversationGroup; + this.groupMemberIds = groupMemberIds; + this.newGroupMemberIds = newGroupMemberIds; + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/event/conversation/SimulationConversationGroupRemoveEvent.java b/src/main/java/club/joylink/rtss/simulation/cbtc/event/conversation/SimulationConversationGroupRemoveEvent.java new file mode 100644 index 000000000..90064702f --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/event/conversation/SimulationConversationGroupRemoveEvent.java @@ -0,0 +1,30 @@ +package club.joylink.rtss.simulation.cbtc.event.conversation; + +import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroup; +import club.joylink.rtss.simulation.cbtc.event.AbstractSimulationEvent; +import club.joylink.rtss.simulation.cbtc.member.SimulationMember; +import lombok.Getter; + +import java.util.List; + +/** + * 群组人员移除事件 + */ +@Getter +public class SimulationConversationGroupRemoveEvent extends AbstractSimulationEvent { + + private ConversationGroup conversationGroup; + + /** + * 被移除的用户ID + */ + private List removeGroupMember; + + public SimulationConversationGroupRemoveEvent(Object source, Simulation simulation, ConversationGroup conversationGroup + , List removeGroupMember) { + super(source, simulation); + this.conversationGroup = conversationGroup; + this.removeGroupMember = removeGroupMember; + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/event/conversation/SimulationConversationGroupUpdateEvent.java b/src/main/java/club/joylink/rtss/simulation/cbtc/event/conversation/SimulationConversationGroupUpdateEvent.java new file mode 100644 index 000000000..4b58b302d --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/event/conversation/SimulationConversationGroupUpdateEvent.java @@ -0,0 +1,20 @@ +package club.joylink.rtss.simulation.cbtc.event.conversation; + +import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroup; +import club.joylink.rtss.simulation.cbtc.event.AbstractSimulationEvent; +import lombok.Getter; + +/** + * 群组信息变更事件 + */ +@Getter +public class SimulationConversationGroupUpdateEvent extends AbstractSimulationEvent { + + private ConversationGroup conversationGroup; + + public SimulationConversationGroupUpdateEvent(Object source, Simulation simulation, ConversationGroup conversationGroup) { + super(source, simulation); + this.conversationGroup = conversationGroup; + } +}