From 99bdbc93cd1b5b7414363cf88534118d6fd5a9b6 Mon Sep 17 00:00:00 2001 From: LEE JIEUN Date: Thu, 5 Dec 2024 17:27:09 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=EB=8C=80=EC=8B=9C=EB=B3=B4?= =?UTF-8?q?=EB=93=9C=20=EC=A1=B0=ED=9A=8C=EC=8B=9C=EC=97=90=20summary=20?= =?UTF-8?q?=EC=97=AC=EB=B6=80=20=ED=8C=90=EB=8B=A8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/api/src/dashboard/dashboard.module.ts | 3 ++- apps/api/src/dashboard/dashboard.service.ts | 30 ++++++++++++++++++--- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/apps/api/src/dashboard/dashboard.module.ts b/apps/api/src/dashboard/dashboard.module.ts index 96823f0f..01d9017b 100644 --- a/apps/api/src/dashboard/dashboard.module.ts +++ b/apps/api/src/dashboard/dashboard.module.ts @@ -2,13 +2,14 @@ import { Module } from '@nestjs/common'; import { TypeOrmModule } from '@nestjs/typeorm'; import { Applicant } from '@/entity/applicant.entity'; +import { Summary } from '@/entity/summary.entity'; import { Ticle } from '@/entity/ticle.entity'; import { DashboardController } from './dashboard.controller'; import { DashboardService } from './dashboard.service'; @Module({ - imports: [TypeOrmModule.forFeature([Ticle, Applicant])], + imports: [TypeOrmModule.forFeature([Ticle, Applicant, Summary])], controllers: [DashboardController], providers: [DashboardService], }) diff --git a/apps/api/src/dashboard/dashboard.service.ts b/apps/api/src/dashboard/dashboard.service.ts index 78b89263..801be71c 100644 --- a/apps/api/src/dashboard/dashboard.service.ts +++ b/apps/api/src/dashboard/dashboard.service.ts @@ -4,6 +4,7 @@ import { Repository } from 'typeorm'; import { ErrorMessage, TicleStatus } from '@repo/types'; import { Applicant } from '@/entity/applicant.entity'; +import { Summary } from '@/entity/summary.entity'; import { Ticle } from '@/entity/ticle.entity'; @Injectable() @@ -12,7 +13,9 @@ export class DashboardService { @InjectRepository(Ticle) private readonly ticleRepository: Repository, @InjectRepository(Applicant) - private readonly applicantRepository: Repository + private readonly applicantRepository: Repository, + @InjectRepository(Summary) + private readonly summaryRepository: Repository ) {} async getCreatedTicleList( @@ -25,7 +28,15 @@ export class DashboardService { const queryBuilder = this.ticleRepository .createQueryBuilder('ticle') - .select(['ticle.id', 'ticle.title', 'ticle.startTime', 'ticle.endTime', 'ticle.ticleStatus']) + .leftJoin('ticle.summary', 'summary') + .select([ + 'ticle.id', + 'ticle.title', + 'ticle.startTime', + 'ticle.endTime', + 'ticle.ticleStatus', + 'summary.id', + ]) .where('ticle.speaker = :speakerId', { speakerId }) .skip(skip) .take(pageSize); @@ -40,7 +51,12 @@ export class DashboardService { } } - const [ticles, totalItems] = await queryBuilder.getManyAndCount(); + const [ticle, totalItems] = await queryBuilder.getManyAndCount(); + + const ticles = ticle.map((ticle) => ({ + ...ticle, + summary: ticle.summary ? ticle.summary.id !== null : false, + })); const totalPages = Math.ceil(totalItems / pageSize); @@ -62,6 +78,7 @@ export class DashboardService { const queryBuilder = this.applicantRepository .createQueryBuilder('applicant') .leftJoinAndSelect('applicant.ticle', 'ticle') + .leftJoin('ticle.summary', 'summary') .select([ 'applicant.id', 'ticle.id', @@ -70,6 +87,7 @@ export class DashboardService { 'ticle.startTime', 'ticle.endTime', 'ticle.ticleStatus', + 'summary.id', ]) .where('applicant.user = :userId', { userId }) .skip(skip) @@ -87,7 +105,11 @@ export class DashboardService { const [applicants, totalItems] = await queryBuilder.getManyAndCount(); - const ticles = applicants.map((applicant) => applicant.ticle); + const ticles = applicants.map((applicant) => ({ + ...applicant.ticle, + summary: applicant.ticle.summary ? applicant.ticle.summary.id !== null : false, // summary 필드 안전하게 처리 + })); + const totalPages = Math.ceil(totalItems / pageSize); return { From 38fae972ce4dce87b213044012223d8167146486 Mon Sep 17 00:00:00 2001 From: LEE JIEUN Date: Thu, 5 Dec 2024 17:47:12 +0900 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=ED=95=84=EC=9A=94=EC=97=86?= =?UTF-8?q?=EB=8A=94=20=EC=A3=BC=EC=84=9D=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/api/src/dashboard/dashboard.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/api/src/dashboard/dashboard.service.ts b/apps/api/src/dashboard/dashboard.service.ts index 801be71c..6bbdf8bb 100644 --- a/apps/api/src/dashboard/dashboard.service.ts +++ b/apps/api/src/dashboard/dashboard.service.ts @@ -107,7 +107,7 @@ export class DashboardService { const ticles = applicants.map((applicant) => ({ ...applicant.ticle, - summary: applicant.ticle.summary ? applicant.ticle.summary.id !== null : false, // summary 필드 안전하게 처리 + summary: applicant.ticle.summary ? applicant.ticle.summary.id !== null : false, })); const totalPages = Math.ceil(totalItems / pageSize);