From 7dd63d48070b96fb9375b9f78ddc0e8ddfbeb521 Mon Sep 17 00:00:00 2001 From: Chooooooo Date: Mon, 26 Feb 2024 16:01:37 +0900 Subject: [PATCH] =?UTF-8?q?Style:=20=EC=BD=94=EB=93=9C=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Swagger에서 nested reqeust body 프로퍼티가 보이게 변경 - 토익 문제 서비스 로직에서 메서드에 불필요한 async 제거 - workbook 파이프에서 upload 서비스를 사용하는 방식 변경 Related to #42 --- .../backend/src/toeic/dto/patch-quesion.dto.ts | 2 ++ packages/backend/src/toeic/toeic.service.ts | 15 ++++++--------- packages/backend/src/upload/pipe/workbook.pipe.ts | 2 +- packages/backend/src/upload/upload.controller.ts | 2 +- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/packages/backend/src/toeic/dto/patch-quesion.dto.ts b/packages/backend/src/toeic/dto/patch-quesion.dto.ts index c443836..7d2f018 100644 --- a/packages/backend/src/toeic/dto/patch-quesion.dto.ts +++ b/packages/backend/src/toeic/dto/patch-quesion.dto.ts @@ -40,6 +40,8 @@ export class PatchToeicWithQuestion implements ToeicReqBodyProps { @ApiProperty({ description: '토익 문제입니다.', + isArray: true, + type: () => PatchQuestion, }) @IsArray() @ValidateNested({ each: true }) diff --git a/packages/backend/src/toeic/toeic.service.ts b/packages/backend/src/toeic/toeic.service.ts index f38c60d..9356b6e 100644 --- a/packages/backend/src/toeic/toeic.service.ts +++ b/packages/backend/src/toeic/toeic.service.ts @@ -7,10 +7,7 @@ import { PatchQuestionToEntity, ToeicWhereInputProps } from './toeic.interface'; export class ToeicService { constructor(private prisma: PrismaService) {} - async createToeic( - filename: string, - questionInSheet: UploadedQuestionInSheet, - ) { + createToeic(filename: string, questionInSheet: UploadedQuestionInSheet) { return this.prisma.toeic.create({ data: { filename, @@ -22,11 +19,11 @@ export class ToeicService { }); } - async findAllToeic(where: ToeicWhereInputProps) { + findAllToeic(where: ToeicWhereInputProps) { return this.prisma.toeic.findMany({ where }); } - async findToeicUnique(id: number) { + findToeicUnique(id: number) { return this.prisma.toeic.findUniqueOrThrow({ where: { id, @@ -37,7 +34,7 @@ export class ToeicService { }); } - async deleteToeicUnique(id: number) { + deleteToeicUnique(id: number) { return this.prisma.toeic.update({ where: { id, @@ -48,7 +45,7 @@ export class ToeicService { }); } - async updateToeicUnique(id: number, data: PatchQuestionToEntity) { + updateToeicUnique(id: number, data: PatchQuestionToEntity) { return this.prisma.toeic.update({ where: { id, @@ -57,7 +54,7 @@ export class ToeicService { }); } - async findQuestionUnique(uuid: string) { + findQuestionUnique(uuid: string) { return this.prisma.question.findUniqueOrThrow({ where: { id: uuid, diff --git a/packages/backend/src/upload/pipe/workbook.pipe.ts b/packages/backend/src/upload/pipe/workbook.pipe.ts index 2846ee7..f7a36c4 100644 --- a/packages/backend/src/upload/pipe/workbook.pipe.ts +++ b/packages/backend/src/upload/pipe/workbook.pipe.ts @@ -13,7 +13,7 @@ import { QuestionInFile } from '../upload.interface'; export class ParseWorkbookPipe implements PipeTransform> { - private readonly uploadService = new UploadService(); + constructor(private readonly uploadService: UploadService) {} async transform(value: Express.Multer.File) { const workbook = readFile(value.path); diff --git a/packages/backend/src/upload/upload.controller.ts b/packages/backend/src/upload/upload.controller.ts index e6278cd..4a59c7d 100644 --- a/packages/backend/src/upload/upload.controller.ts +++ b/packages/backend/src/upload/upload.controller.ts @@ -35,7 +35,7 @@ export class UploadController { new ParseFilePipe({ validators: [new FileTypeValidator({ fileType: 'sheet' })], }), - new ParseWorkbookPipe(), + ParseWorkbookPipe, ) file: QuestionInFile, ) {