From 732c3d180bb2271ab6956e911a8d16302e680914 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Wed, 11 Mar 2026 15:51:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=B8=E6=88=8F=E6=96=B0=E5=A2=9EgameInfo?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../game/ludo/GameLudoCreateCmdExe.java | 26 ++++++++++++------- .../dto/clientobject/game/GameLudoRunCO.java | 19 ++++++++++++++ .../app/dto/cmd/game/GameLudoCreateCmd.java | 5 ++++ .../mongo/entity/game/ludo/GameLudoRun.java | 20 ++++++++++++++ 4 files changed, 60 insertions(+), 10 deletions(-) diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/game/ludo/GameLudoCreateCmdExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/game/ludo/GameLudoCreateCmdExe.java index 2f7dc3de..58b3deca 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/game/ludo/GameLudoCreateCmdExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/game/ludo/GameLudoCreateCmdExe.java @@ -1,15 +1,13 @@ package com.red.circle.other.app.command.game.ludo; import com.red.circle.component.redis.service.RedisService; -import com.red.circle.external.inner.endpoint.message.ImGroupClient; -import com.red.circle.external.inner.model.cmd.message.BroadcastGroupMsgBodyCmd; -import com.red.circle.external.inner.model.enums.message.GroupMessageTypeEnum; import com.red.circle.framework.core.asserts.ResponseAssert; import com.red.circle.framework.core.response.CommonErrorCode; import com.red.circle.framework.web.props.EnvProperties; import com.red.circle.other.app.convertor.game.GameLudoAppConvertor; import com.red.circle.other.app.convertor.user.UserProfileAppConvertor; import com.red.circle.other.app.dto.clientobject.game.GameLudoRunCO; +import com.red.circle.other.infra.database.rds.entity.sys.GameListConfig; import com.red.circle.other.app.dto.cmd.game.GameLudoCreateCmd; import com.red.circle.other.domain.gateway.user.UserProfileGateway; import com.red.circle.other.infra.database.cache.service.other.GameCacheService; @@ -20,6 +18,7 @@ import com.red.circle.other.infra.database.mongo.entity.game.ludo.GameStatus; import com.red.circle.other.infra.database.mongo.entity.game.ludo.GameStatusEvent; import com.red.circle.other.infra.database.mongo.service.game.GameLudoRunService; import com.red.circle.other.infra.database.rds.service.live.RoomMemberService; +import com.red.circle.other.infra.database.rds.service.sys.GameListConfigService; import com.red.circle.other.inner.asserts.GameErrorCode; import com.red.circle.other.inner.asserts.user.UserErrorCode; import com.red.circle.other.inner.enums.live.RoomUserRolesEnum; @@ -47,7 +46,6 @@ public class GameLudoCreateCmdExe { private final RedisService redisService; private final EnvProperties envProperties; - private final ImGroupClient imGroupClient; private final WalletGoldClient walletGoldClient; private final GameCacheService gameCacheService; private final RoomMemberService roomMemberService; @@ -55,6 +53,7 @@ public class GameLudoCreateCmdExe { private final GameLudoRunService gameLudoRunService; private final GameLudoAppConvertor gameLudoAppConvertor; private final UserProfileAppConvertor userProfileAppConvertor; + private final GameListConfigService gameListConfigService; public GameLudoRunCO execute(GameLudoCreateCmd cmd) { @@ -76,15 +75,14 @@ public class GameLudoCreateCmdExe { ResponseAssert.isFalse(GameErrorCode.GAME_CREATED, gameLudoRunService.exists(cmd.getRoomId())); - gameLudoRun = createGameLudoRun(cmd); + GameListConfig gameListConfig = gameListConfigService.getById(cmd.getGameId()); + ResponseAssert.notNull(GameErrorCode.GAME_NOT_EXIST, gameListConfig); + + gameLudoRun = createGameLudoRun(cmd, gameListConfig); ResponseAssert.isTrue(GameErrorCode.GAME_CREATED, gameLudoRunService.create(gameLudoRun)); gameCacheService.inrJoinNumberPeopleLudo(gameLudoRun.getId()); gameCacheService.setJoinGameLudo(gameLudoRun.getId(), gameLudoRun.getUserId()); - imGroupClient - .sendMessageBroadcast( - BroadcastGroupMsgBodyCmd.builder().type(GroupMessageTypeEnum.CREATE_GAME_LUDO) - .data(gameLudoRun.getId()).toPlatform(cmd.requireReqSysOriginEnum()).build()); } finally { redisService.unlock(lockKey(cmd)); } @@ -95,16 +93,24 @@ public class GameLudoCreateCmdExe { return "CREATE_LUDO".concat(cmd.getRoomId().toString()); } - private GameLudoRun createGameLudoRun(GameLudoCreateCmd cmd) { + private GameLudoRun createGameLudoRun(GameLudoCreateCmd cmd, GameListConfig config) { BigDecimal consumeAmount = consumeAmount(cmd); UserProfileDTO userProfile = userProfileAppConvertor.toUserProfileDTO( userProfileGateway.getByUserId(cmd.getHomeownerUserId())); ResponseAssert.notNull(UserErrorCode.USER_INFO_NOT_FOUND, userProfile); + GameLudoRun.GameInfo gameInfo = new GameLudoRun.GameInfo(); + gameInfo.setId(config.getId()); + gameInfo.setGameId(config.getGameId()); + gameInfo.setName(config.getName()); + gameInfo.setGameCode(config.getGameCode()); + gameInfo.setCover(config.getCover()); return new GameLudoRun() .setId(cmd.getRoomId()) .setSysOrigin(cmd.getReqSysOrigin().getOrigin()) .setRoomId(cmd.getRoomId()) .setUserId(cmd.getHomeownerUserId()) + .setGameId(cmd.getGameId()) + .setGameInfo(gameInfo) .setGameStatus(GameStatus.WAIT) .setGameStatusEvent(GameStatusEvent.NONE) .setJoinAmount(cmd.getAmount()) diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/game/GameLudoRunCO.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/game/GameLudoRunCO.java index 7809c25b..af94b7bf 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/game/GameLudoRunCO.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/game/GameLudoRunCO.java @@ -79,5 +79,24 @@ public class GameLudoRunCO extends ClientObject { */ private Timestamp createTime; + /** + * 游戏信息. + */ + private GameInfo gameInfo; + + @Data + public static class GameInfo { + + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + private String gameId; + + private String name; + + private String gameCode; + + private String cover; + } } diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/game/GameLudoCreateCmd.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/game/GameLudoCreateCmd.java index 587623e3..bcef3300 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/game/GameLudoCreateCmd.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/game/GameLudoCreateCmd.java @@ -40,6 +40,11 @@ public class GameLudoCreateCmd extends AppExtCommand { @NotNull(message = "localSeat required.") private String localSeat; + /** + * 游戏ID + */ + private Long gameId; + /** * 房主id. * diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/mongo/entity/game/ludo/GameLudoRun.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/mongo/entity/game/ludo/GameLudoRun.java index 7a1c8c17..fcd4c783 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/mongo/entity/game/ludo/GameLudoRun.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/mongo/entity/game/ludo/GameLudoRun.java @@ -50,6 +50,26 @@ public class GameLudoRun implements Serializable { @JsonSerialize(using = ToStringSerializer.class) private Long userId; + /** + * 游戏ID(游戏列表的ID) + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long gameId; + + /** + * 游戏信息快照. + */ + private GameInfo gameInfo; + + @Data + public static class GameInfo { + private Long id; + private String gameId; + private String name; + private String gameCode; + private String cover; + } + /** * 游戏状态. */