Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修复群主退群bug #156

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,9 @@ public void refreshOrCreateActiveTime(Long roomId, List<Long> memberUidList, Lon
* @return 是否删除成功
*/
public Boolean removeByRoomId(Long roomId, List<Long> uidList) {
if (CollectionUtil.isNotEmpty(uidList)) {
LambdaQueryWrapper<Contact> wrapper = new QueryWrapper<Contact>().lambda()
.eq(Contact::getRoomId, roomId)
.in(Contact::getUid, uidList);
return this.remove(wrapper);
}
return false;
LambdaQueryWrapper<Contact> wrapper = new QueryWrapper<Contact>().lambda()
.eq(Contact::getRoomId, roomId)
.in(Contact::getUid, uidList);
return this.remove(wrapper);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,10 @@ public void revokeAdmin(Long id, List<Long> uidList) {
* @return 是否删除成功
*/
public Boolean removeByGroupId(Long groupId, List<Long> uidList) {
if (CollectionUtil.isNotEmpty(uidList)) {
LambdaQueryWrapper<GroupMember> wrapper = new QueryWrapper<GroupMember>()
.lambda()
.eq(GroupMember::getGroupId, groupId)
.in(GroupMember::getUid, uidList);
return this.remove(wrapper);
}
return false;
LambdaQueryWrapper<GroupMember> wrapper = new QueryWrapper<GroupMember>()
.lambda()
.eq(GroupMember::getGroupId, groupId)
.in(GroupMember::getUid, uidList);
return this.remove(wrapper);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,10 @@ public Integer getUnReadCount(Long roomId, Date readTime) {
* @return 是否删除成功
*/
public Boolean removeByRoomId(Long roomId, List<Long> uidList) {
if (CollectionUtil.isNotEmpty(uidList)) {
LambdaUpdateWrapper<Message> wrapper = new UpdateWrapper<Message>().lambda()
.eq(Message::getRoomId, roomId)
.in(Message::getFromUid, uidList)
.set(Message::getStatus, MessageStatusEnum.DELETE.getStatus());
return this.update(wrapper);
}
return false;
LambdaUpdateWrapper<Message> wrapper = new UpdateWrapper<Message>().lambda()
.eq(Message::getRoomId, roomId)
.in(Message::getFromUid, uidList)
.set(Message::getStatus, MessageStatusEnum.DELETE.getStatus());
return this.update(wrapper);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,15 @@ public void exitGroup(Long uid, MemberExitReq request) {
boolean isDelRoom = roomDao.removeById(roomId);
AssertUtil.isTrue(isDelRoom, CommonErrorEnum.SYSTEM_ERROR);
// 4.2 删除会话
Boolean isDelContact = contactDao.removeByRoomId(roomId, Collections.EMPTY_LIST);
// add: 查询房间内所有成员ID
List<Long> memberUidList = groupMemberDao.getMemberUidList(roomGroup.getId());
Boolean isDelContact = contactDao.removeByRoomId(roomId, memberUidList);
AssertUtil.isTrue(isDelContact, CommonErrorEnum.SYSTEM_ERROR);
// 4.3 删除群成员
Boolean isDelGroupMember = groupMemberDao.removeByGroupId(roomGroup.getId(), Collections.EMPTY_LIST);
Boolean isDelGroupMember = groupMemberDao.removeByGroupId(roomGroup.getId(), memberUidList);
AssertUtil.isTrue(isDelGroupMember, CommonErrorEnum.SYSTEM_ERROR);
// 4.4 删除消息记录 (逻辑删除)
Boolean isDelMessage = messageDao.removeByRoomId(roomId, Collections.EMPTY_LIST);
Boolean isDelMessage = messageDao.removeByRoomId(roomId, memberUidList);
AssertUtil.isTrue(isDelMessage, CommonErrorEnum.SYSTEM_ERROR);
// TODO 这里也可以告知群成员 群聊已被删除的消息
} else {
Expand Down