From 8fec022029b1a3b675e8965c22108213d7fc1cec Mon Sep 17 00:00:00 2001 From: SiWooJinSeok <59861974+SiWooJinSeok@users.noreply.github.com> Date: Mon, 13 May 2024 17:10:12 +0900 Subject: [PATCH] =?UTF-8?q?fix=20:=20=EC=9C=A0=EC=A0=80=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EC=A0=84=EB=8B=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/internal/internal.controller.ts | 2 +- src/internal/internal.service.ts | 25 +++++++++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/internal/internal.controller.ts b/src/internal/internal.controller.ts index 55abf01..579b90f 100644 --- a/src/internal/internal.controller.ts +++ b/src/internal/internal.controller.ts @@ -8,7 +8,7 @@ export class InternalController { constructor(private readonly internalService: InternalService) {} @Post('users') - async getUserNames(@Body() userDto: UserByIdsDto): Promise { + async getUserNames(@Body() userDto: UserByIdsDto) { return this.internalService.getUserByIds(userDto.ids); } diff --git a/src/internal/internal.service.ts b/src/internal/internal.service.ts index 54b14e7..73e2194 100644 --- a/src/internal/internal.service.ts +++ b/src/internal/internal.service.ts @@ -11,13 +11,26 @@ export class InternalService { @Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger, ) {} - async getUserByIds(userIds: number[]): Promise { + async getUserByIds(userIds: number[]) { const users = await Promise.all( - userIds.map((userId) => - this.prismaService.user.findUnique({ - where: { id: userId }, - }), - ), + userIds.map(async (userId) => { + const user = await this.prismaService.user.findUnique({ + where: { + id: userId, + }, + include: { + state: true, + }, + }); + + return { + id: user.id, + email: user.email, + nickname: user.nickname, + state: user.state?.name || null, + imageUrl: user.imageUrl || '', + }; + }), ); return users; }