房间发现列表新增 房间图标字段

This commit is contained in:
tianfeng 2026-03-11 18:27:43 +08:00
parent 227ed9c410
commit 020fc3e543
5 changed files with 50 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import com.red.circle.common.business.enums.SVIPLevelEnum;
import com.red.circle.live.inner.endpoint.LiveMicClient;
import com.red.circle.other.app.common.room.RoomVoiceProfileCommon;
import com.red.circle.other.app.dto.clientobject.room.RoomVoiceProfileCO;
import com.red.circle.other.app.service.game.GameLudoService;
import com.red.circle.other.app.service.room.RocketStatusCacheService;
import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway;
import com.red.circle.other.domain.gateway.user.ability.UserSVipGateway;
@ -57,7 +58,8 @@ public class RoomVoiceDiscoverQryExe {
private final RegionRoomCacheService regionRoomCacheService;
private final LiveMicClient liveMicClient;
private final RedisTemplate<String, Object> redisTemplate;
private final RocketStatusCacheService rocketStatusCacheService;
private final RocketStatusCacheService rocketStatusCacheService;
private final GameLudoService gameLudoService;
private static final String EMPTY_ROOM_CACHE_KEY = "empty_room_cache:*";
@ -115,10 +117,21 @@ public class RoomVoiceDiscoverQryExe {
// 填充火箭状态
fillRocketStatus(roomList);
// 填充游戏图标
fillGameIcon(roomList);
return roomList;
}
private void fillGameIcon(List<RoomVoiceProfileCO> roomList) {
if (CollectionUtils.isEmpty(roomList)) {
return;
}
List<Long> roomIds = roomList.stream().map(RoomVoiceProfileCO::getId).toList();
Map<Long, String> coverMap = gameLudoService.listGameCoverByRoomIds(roomIds);
roomList.forEach(room -> room.setRoomGameIcon(coverMap.get(room.getId())));
}
/**
* 填充房间的火箭状态信息
*

View File

@ -11,6 +11,12 @@ import com.red.circle.other.app.command.game.ludo.GameLudoStartCmdExe;
import com.red.circle.other.app.command.game.ludo.GameRoomExistsQueryExe;
import com.red.circle.other.app.dto.clientobject.game.GameLudoRunCO;
import com.red.circle.other.app.dto.cmd.game.GameLudoCreateCmd;
import com.red.circle.other.infra.database.mongo.entity.game.ludo.GameLudoRun;
import com.red.circle.other.infra.database.mongo.service.game.GameLudoRunService;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import com.red.circle.other.app.dto.cmd.game.GameLudoEndCmd;
import com.red.circle.other.app.dto.cmd.game.GameLudoJoinCmd;
import com.red.circle.other.app.dto.cmd.game.GameLudoStartCmd;
@ -34,6 +40,7 @@ public class GameLudoServiceImpl implements GameLudoService {
private final GameLudoRoomRunQueryExe gameLudoRoomRunQueryExe;
private final GameLudoLatestEndCmdExe gameLudoLatestEndCmdExe;
private final GameLudoLatestDisbandCmdExe gameLudoLatestDisbandCmdExe;
private final GameLudoRunService gameLudoRunService;
@Override
public GameLudoRunCO getRoomGame(AppRoomIdCmd cmd) {
@ -70,4 +77,11 @@ public class GameLudoServiceImpl implements GameLudoService {
gameLudoLatestEndCmdExe.execute(cmd);
}
@Override
public Map<Long, String> listGameCoverByRoomIds(List<Long> roomIds) {
return gameLudoRunService.listByRoomIds(roomIds).stream()
.filter(run -> Objects.nonNull(run.getGameInfo()) && Objects.nonNull(run.getGameInfo().getCover()))
.collect(Collectors.toMap(GameLudoRun::getRoomId, run -> run.getGameInfo().getCover(), (a, b) -> a));
}
}

View File

@ -3,6 +3,8 @@ package com.red.circle.other.app.service.game;
import com.red.circle.common.business.dto.cmd.app.AppIdLongCmd;
import com.red.circle.common.business.dto.cmd.app.AppRoomIdCmd;
import com.red.circle.other.app.dto.clientobject.game.GameLudoRunCO;
import java.util.List;
import java.util.Map;
import com.red.circle.other.app.dto.cmd.game.GameLudoCreateCmd;
import com.red.circle.other.app.dto.cmd.game.GameLudoEndCmd;
import com.red.circle.other.app.dto.cmd.game.GameLudoJoinCmd;
@ -29,4 +31,9 @@ public interface GameLudoService {
void end(GameLudoEndCmd cmd);
/**
* 批量获取房间正在进行的游戏封面key=roomIdvalue=cover
*/
Map<Long, String> listGameCoverByRoomIds(List<Long> roomIds);
}

View File

@ -47,4 +47,9 @@ public interface GameLudoRunService {
* 移除房间游戏.
*/
void remove(Long id);
/**
* 批量查询房间游戏.
*/
List<GameLudoRun> listByRoomIds(List<Long> roomIds);
}

View File

@ -82,6 +82,16 @@ public class GameLudoRunServiceImpl implements GameLudoRunService {
GameLudoRun.class);
}
@Override
public List<GameLudoRun> listByRoomIds(List<Long> roomIds) {
if (roomIds == null || roomIds.isEmpty()) {
return List.of();
}
return mongoTemplate.find(
Query.query(Criteria.where("id").in(roomIds)),
GameLudoRun.class);
}
@Override
public void remove(Long id) {
mongoTemplate.remove(Query.query(Criteria.where("id").is(id)), GameLudoRun.class);