@@ -7,6 +7,7 @@ import { InjectRepository } from '@nestjs/typeorm';
77import { Repository } from 'typeorm' ;
88import { GameRoom } from './entities/gameRoom.entity' ;
99import { GameRoomUser } from './entities/gameRoomUser.entity' ;
10+ import { UserService } from 'src/user/user.service' ;
1011
1112@Injectable ( )
1213export class GameRoomService {
@@ -15,6 +16,7 @@ export class GameRoomService {
1516 private readonly gameRoomRepository : Repository < GameRoom > ,
1617 @InjectRepository ( GameRoomUser )
1718 private readonly gameRoomUserRepository : Repository < GameRoomUser > ,
19+ private readonly userService : UserService ,
1820 ) { }
1921
2022 // ─────────────────────────────────────────
@@ -176,13 +178,23 @@ export class GameRoomService {
176178
177179 // DB에서 인원 목록 조회
178180 const users = await this . gameRoomUserRepository . find ( { where : { roomId } } ) ;
181+ console . log ( users ) ;
182+ const usersWithNicknames = await Promise . all (
183+ users . map ( async ( user ) => {
184+ const userData = await this . userService . findUserById ( user . userId ) ;
185+ return {
186+ ...user ,
187+ userNickname : userData . userNickname ,
188+ } ;
189+ } ) ,
190+ ) ;
179191
180192 // (선택) 혹시 최신 인원수를 다시 덮어씌우고 싶다면:
181193 // const count = await this.gameRoomUserRepository.count({ where: { roomId } });
182194 // room.currentCount = count;
183195 // await this.gameRoomRepository.save(room);
184196
185- return { room, users } ;
197+ return { room, users : usersWithNicknames } ;
186198 }
187199
188200 // ─────────────────────────────────────────
0 commit comments