Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
zongzibinbin committed Oct 22, 2023
2 parents 0d2126f + c1dfc7d commit 7fc1cfd
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
Expand Down Expand Up @@ -50,4 +51,20 @@ public List<GroupMember> getSelfGroup(Long uid) {
.eq(GroupMember::getRole, GroupRoleEnum.LEADER.getType())
.list();
}

/**
* 批量获取成员群角色
*
* @param groupId 群ID
* @param uidList 用户列表
* @return 成员群角色列表
*/
public Map<Long, Integer> getMemberMapRole(Long groupId, List<Long> uidList) {
List<GroupMember> list = lambdaQuery()
.eq(GroupMember::getGroupId, groupId)
.in(GroupMember::getUid, uidList)
.select(GroupMember::getUid, GroupMember::getRole)
.list();
return list.stream().collect(Collectors.toMap(GroupMember::getUid, GroupMember::getRole));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public interface ChatService {
* @param request
* @return
*/
CursorPageBaseResp<ChatMemberResp> getMemberPage(List<Long> memberUidList, CursorPageBaseReq request);
CursorPageBaseResp<ChatMemberResp> getMemberPage(List<Long> memberUidList, MemberReq request);

/**
* 获取消息列表
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public class ChatServiceImpl implements ChatService {
@Autowired
private RoomGroupCache roomGroupCache;
@Autowired
private MQProducer mqProducer;
private RoomGroupDao roomGroupDao;

/**
* 发送消息
Expand Down Expand Up @@ -141,7 +141,7 @@ public ChatMessageResp getMsgResp(Long msgId, Long receiveUid) {
}

@Override
public CursorPageBaseResp<ChatMemberResp> getMemberPage(List<Long> memberUidList, CursorPageBaseReq request) {
public CursorPageBaseResp<ChatMemberResp> getMemberPage(List<Long> memberUidList, MemberReq request) {
Pair<ChatActiveStatusEnum, String> pair = ChatMemberHelper.getCursorPair(request.getCursor());
ChatActiveStatusEnum activeStatusEnum = pair.getKey();
String timeCursor = pair.getValue();
Expand All @@ -164,6 +164,11 @@ public CursorPageBaseResp<ChatMemberResp> getMemberPage(List<Long> memberUidList
timeCursor = cursorPage.getCursor();
isLast = cursorPage.getIsLast();
}
// 获取群成员角色ID
List<Long> uidList = resultList.stream().map(ChatMemberResp::getUid).collect(Collectors.toList());
RoomGroup roomGroup = roomGroupDao.getByRoomId(request.getRoomId());
Map<Long, Integer> uidMapRole = groupMemberDao.getMemberMapRole(roomGroup.getId(), uidList);
resultList.forEach(member -> member.setRoleId(uidMapRole.get(member.getUid())));
//组装结果
return new CursorPageBaseResp<>(ChatMemberHelper.generateCursor(activeStatusEnum, timeCursor), isLast, resultList);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ public class ChatMemberResp {
*/
@ApiModelProperty("在线状态 1在线 2离线")
private Integer activeStatus;

/**
* 角色ID
*/
private Integer roleId;

@ApiModelProperty("最后一次上下线时间")
private Date lastOptTime;
}

0 comments on commit 7fc1cfd

Please sign in to comment.