diff --git a/BackEnd/src/config/typeorm.config.ts b/BackEnd/src/config/typeorm.config.ts index 379d9edb..039765c4 100644 --- a/BackEnd/src/config/typeorm.config.ts +++ b/BackEnd/src/config/typeorm.config.ts @@ -14,4 +14,7 @@ export const typeOrmConfig: TypeOrmModuleOptions = { synchronize: false, logging: true, charset: 'utf8mb4', + extra: { + connectionLimit: 10, + } }; diff --git a/BackEnd/src/records/dto/record-response.dto.ts b/BackEnd/src/records/dto/record-response.dto.ts index ebb3c8e1..4405bf3f 100644 --- a/BackEnd/src/records/dto/record-response.dto.ts +++ b/BackEnd/src/records/dto/record-response.dto.ts @@ -1,9 +1,9 @@ import { ApiProperty, PickType } from '@nestjs/swagger'; import { SuccessResDto } from '../../common/dto/SuccessRes.dto'; import { Record } from '../entities/records.entity'; - +import { Workout } from 'src/workouts/entities/workout.entity'; +class WorkoutDto extends PickType(Workout, ['name']) {} class GetRecord extends PickType(Record, [ - 'workout', 'profile', 'workoutTime', 'distance', @@ -14,21 +14,20 @@ class GetRecord extends PickType(Record, [ 'createdAt', 'mapCapture', 'gps' -]) {} - +]) { + @ApiProperty( {type: () => WorkoutDto} ) + workout: WorkoutDto; +} class GetRecordWithId extends PickType(Record, ['id']) {} - export class CreateRecordResDto extends SuccessResDto { @ApiProperty({ type: () => GetRecordWithId }) data: Pick; } - export class GetUsersRecordsResDto extends SuccessResDto { @ApiProperty({ type: () => [GetRecord] }) data: GetRecord[]; } - export class GetRecordResDto extends SuccessResDto { @ApiProperty({ type: () => GetRecord }) data: GetRecord; -} +} \ No newline at end of file diff --git a/BackEnd/src/records/entities/records.entity.ts b/BackEnd/src/records/entities/records.entity.ts index 9d77e1c1..bb9f0f4c 100644 --- a/BackEnd/src/records/entities/records.entity.ts +++ b/BackEnd/src/records/entities/records.entity.ts @@ -96,7 +96,7 @@ export class Record { @Column({ default: false }) isPosted: boolean; - @ManyToOne(() => Profile, (profile) => profile.records) //manyToOne이 항상 외래키를 갖고 있음 + @ManyToOne(() => Profile, (profile) => profile.records) profile: Profile; @OneToOne(() => Post, (post) => post.record) diff --git a/BackEnd/src/records/records.service.ts b/BackEnd/src/records/records.service.ts index 7134769f..9bb79418 100644 --- a/BackEnd/src/records/records.service.ts +++ b/BackEnd/src/records/records.service.ts @@ -30,7 +30,8 @@ export class RecordsService { findByDate(profileId: number, year: number, month: number, day: number) { return this.recordsRepository .createQueryBuilder('record') - .leftJoinAndSelect('record.workout', 'workout') + .leftJoin('record.workout', 'workout') + .addSelect('workout.name') .where('record.profileId = :profileId', { profileId }) .andWhere( `YEAR(record.createdAt) = :year AND MONTH(record.createdAt) = :month AND DAY(record.createdAt) = :day`, @@ -40,11 +41,13 @@ export class RecordsService { } async findById(recordId: number) { - const result = await this.recordsRepository.findOne({ - where: { - id: recordId, - }, - }); + const result = await this.recordsRepository + .createQueryBuilder('record') + .leftJoin('record.workout', 'workout') + .addSelect('workout.name') + .where('record.id = :recordId', { recordId }) + .getOne(); + if (!result) { throw new NotFoundRecordException(); }