|
@@ -112,6 +112,10 @@ public class RoomServiceImpl extends ServiceImpl<RoomMapper, RoomEntity> impleme
|
|
|
// 加入房间记录
|
|
|
GameLogEntity entity = gameLogService.findByRoomIdAndUserId(roomId, userId, type);
|
|
|
if (entity == null){
|
|
|
+
|
|
|
+ // 最多9人加入该房间号
|
|
|
+ checkSzieByRoomId(9, roomId);
|
|
|
+
|
|
|
log.info("需要创建该房间的游戏记录");
|
|
|
// 用户加入房间
|
|
|
entity = new GameLogEntity();
|
|
@@ -125,6 +129,16 @@ public class RoomServiceImpl extends ServiceImpl<RoomMapper, RoomEntity> impleme
|
|
|
return Result.success(entity);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 2022-06-22
|
|
|
+ * 检查加入房间人数
|
|
|
+ * @param size
|
|
|
+ */
|
|
|
+ private void checkSzieByRoomId(int size, Long roomId){
|
|
|
+ Long count = gameLogService.countByRoomId(roomId);
|
|
|
+ BaseRuntimeException.isTrue(count >= size, 3100, "房间人数已满");
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
|