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..6bbdf8bb 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, + })); + const totalPages = Math.ceil(totalItems / pageSize); return {