游玩记录 过滤下架的游戏
This commit is contained in:
parent
47e926cfec
commit
3a08c5d612
@ -3,8 +3,13 @@ package com.red.circle.other.app.command.game;
|
||||
import com.red.circle.other.app.dto.clientobject.game.GamePlayHistoryCO;
|
||||
import com.red.circle.other.infra.database.mongo.entity.game.UserGamePlayHistory;
|
||||
import com.red.circle.other.infra.database.mongo.service.game.UserGamePlayHistoryService;
|
||||
import com.red.circle.other.infra.database.rds.entity.sys.GameListConfig;
|
||||
import com.red.circle.other.infra.database.rds.service.sys.GameListConfigService;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -21,13 +26,31 @@ public class GamePlayHistoryQryExe {
|
||||
private static final int RECENT_LIMIT = 10;
|
||||
|
||||
private final UserGamePlayHistoryService userGamePlayHistoryService;
|
||||
private final GameListConfigService gameListConfigService;
|
||||
|
||||
public List<GamePlayHistoryCO> execute(String sysOrigin, Long userId, String scene) {
|
||||
List<UserGamePlayHistory> historyList =
|
||||
userGamePlayHistoryService.listRecent(sysOrigin, userId, scene, RECENT_LIMIT);
|
||||
|
||||
if (historyList.isEmpty()) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
Set<Long> configIds = historyList.stream()
|
||||
.map(UserGamePlayHistory::getGameListConfigId)
|
||||
.collect(Collectors.toSet());
|
||||
Map<Long, GameListConfig> configMap = gameListConfigService.query()
|
||||
.in(GameListConfig::getId, configIds)
|
||||
.list()
|
||||
.stream()
|
||||
.collect(Collectors.toMap(GameListConfig::getId, Function.identity()));
|
||||
|
||||
return historyList.stream()
|
||||
.filter(h -> Objects.nonNull(h.getGameInfo()))
|
||||
.filter(h -> {
|
||||
GameListConfig config = configMap.get(h.getGameListConfigId());
|
||||
return config != null && Boolean.TRUE.equals(config.getShowcase());
|
||||
})
|
||||
.map(this::toCO)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@ -28,6 +28,7 @@ public class GamePlayHistoryRecordCmdExe {
|
||||
public void execute(GamePlayHistoryRecordCmd cmd) {
|
||||
GameListConfig config = gameListConfigService.getById(cmd.getGameListConfigId());
|
||||
ResponseAssert.notNull(GameErrorCode.GAME_NOT_EXIST, config);
|
||||
ResponseAssert.isTrue(GameErrorCode.GAME_NOT_EXIST, Boolean.TRUE.equals(config.getShowcase()));
|
||||
|
||||
GameInfo gameInfo = new GameInfo();
|
||||
gameInfo.setId(config.getId());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user