From 179f5b275000ebb6c5ab5dea3043d5cc643292c5 Mon Sep 17 00:00:00 2001 From: ndaemy Date: Mon, 13 Feb 2023 23:46:23 +0900 Subject: [PATCH 1/6] =?UTF-8?q?feat:=20=EC=A7=80=EC=9B=90=EC=84=9C=206?= =?UTF-8?q?=EB=B2=88=EC=A7=B8=20=EB=AC=B8=ED=95=AD=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/applications/application.entity.ts | 6 ------ src/api/applications/dto/create-application.dto.ts | 11 ----------- 2 files changed, 17 deletions(-) diff --git a/src/api/applications/application.entity.ts b/src/api/applications/application.entity.ts index 73d0fc1..bdab1be 100644 --- a/src/api/applications/application.entity.ts +++ b/src/api/applications/application.entity.ts @@ -21,7 +21,6 @@ type ApplicationForm = { thirdAnswer: string; fourthAnswer: string; fifthAnswer: string; - sixthAnswer: string; }; @Entity('Application') @@ -74,9 +73,6 @@ export class Application { @Column({ nullable: true }) fifthAnswer: string; - @Column({ nullable: true }) - sixthAnswer: string; - @CreateDateColumn() createdDate: Date; @@ -98,7 +94,6 @@ export class Application { thirdAnswer, fourthAnswer, fifthAnswer, - sixthAnswer, }: ApplicationForm): Application { const application = new Application(); @@ -117,7 +112,6 @@ export class Application { application.thirdAnswer = thirdAnswer; application.fourthAnswer = fourthAnswer; application.fifthAnswer = fifthAnswer; - application.sixthAnswer = sixthAnswer; return application; } diff --git a/src/api/applications/dto/create-application.dto.ts b/src/api/applications/dto/create-application.dto.ts index 3b6d22e..076283e 100644 --- a/src/api/applications/dto/create-application.dto.ts +++ b/src/api/applications/dto/create-application.dto.ts @@ -86,9 +86,6 @@ class PersonalInfo { readonly personalInfoAgreement: true; } -/** - * 문항은 최대 6개일 것이라고 가정 - */ class ApplicationInfo { @ApiProperty({ example: 'https://example.com/cv.zip', @@ -137,14 +134,6 @@ class ApplicationInfo { @IsString() @MaxLength(1000) readonly fifthAnswer: string; - - @ApiProperty({ - example: '여섯 번째 문항 답변입니다.', - description: '여섯 번째 문항 답변 (1000자 이하)', - }) - @IsString() - @MaxLength(1000) - readonly sixthAnswer: string; } export class CreateApplicationDto { From 5a300bc03f0c7894977e20b81e9c9faad14519d2 Mon Sep 17 00:00:00 2001 From: ndaemy Date: Mon, 13 Feb 2023 23:51:01 +0900 Subject: [PATCH 2/6] =?UTF-8?q?feat:=20=EB=94=94=EC=A7=80=EB=AA=AC=20?= =?UTF-8?q?=ED=8C=8C=ED=8A=B8=EB=8A=94=20=EC=9E=90=EA=B8=B0=EC=86=8C?= =?UTF-8?q?=EA=B0=9C=EC=84=9C=20=ED=8C=8C=EC=9D=BC=EC=9D=B4=20=EC=97=86?= =?UTF-8?q?=EA=B3=A0=205=EB=B2=88=EC=A7=B8=20=EB=AC=B8=ED=95=AD=EC=9D=B4?= =?UTF-8?q?=20=EC=97=86=EC=9D=84=20=EC=88=98=20=EC=9E=88=EC=9D=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/applications/dto/create-application.dto.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/api/applications/dto/create-application.dto.ts b/src/api/applications/dto/create-application.dto.ts index 076283e..472175e 100644 --- a/src/api/applications/dto/create-application.dto.ts +++ b/src/api/applications/dto/create-application.dto.ts @@ -5,6 +5,7 @@ import { IsEmail, IsIn, IsObject, + IsOptional, IsString, IsUrl, Matches, @@ -91,6 +92,7 @@ class ApplicationInfo { example: 'https://example.com/cv.zip', description: '자기소개서 링크 (URL)', }) + @IsOptional() @IsUrl() @MaxLength(512) readonly cvUrl: string; @@ -131,6 +133,8 @@ class ApplicationInfo { example: '다섯 번째 문항 답변입니다.', description: '다섯 번째 문항 답변 (1000자 이하)', }) + // 디지몬 파트는 다섯 번째 문항이 없으므로 Optional + @IsOptional() @IsString() @MaxLength(1000) readonly fifthAnswer: string; From d8108a979367c714d9525bf9dee6a912480fe5f7 Mon Sep 17 00:00:00 2001 From: ndaemy Date: Tue, 14 Feb 2023 00:00:03 +0900 Subject: [PATCH 3/6] =?UTF-8?q?feat:=20=EB=94=94=EC=A7=80=EB=AA=AC=20?= =?UTF-8?q?=ED=8C=8C=ED=8A=B8=EA=B0=80=20=EC=95=84=EB=8B=90=20=EA=B2=BD?= =?UTF-8?q?=EC=9A=B0=20cvUrl=20=EA=B3=BC=20fifthAnswer=20=EA=B0=80=20?= =?UTF-8?q?=EC=A1=B4=EC=9E=AC=ED=95=B4=EC=95=BC=20=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/applications/applications.service.ts | 23 +++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/api/applications/applications.service.ts b/src/api/applications/applications.service.ts index baba96b..1c9655e 100644 --- a/src/api/applications/applications.service.ts +++ b/src/api/applications/applications.service.ts @@ -1,5 +1,5 @@ import { PutObjectCommand } from '@aws-sdk/client-s3'; -import { Injectable } from '@nestjs/common'; +import { BadRequestException, HttpException, Injectable } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; import { Repository } from 'typeorm'; @@ -17,6 +17,27 @@ export class ApplicationsService { async create(createApplicationDto: CreateApplicationDto) { const { personalInfo, applicationInfo } = createApplicationDto; + // 디지몬 파트가 아닌데 자기소개서가 없으면 400 에러 + if (personalInfo.part !== 'design') { + const errors: string[] = []; + + if (!applicationInfo.cvUrl) { + errors.push( + "applicationInfo.cvUrl must be exist when personalInfo.part isn't design", + ); + } + + if (!applicationInfo.fifthAnswer) { + errors.push( + "applicationInfo.fifthAnswer must be exist when personalInfo.part isn't design", + ); + } + + if (errors.length > 0) { + throw new BadRequestException(errors); + } + } + const application = Application.from({ ...personalInfo, ...applicationInfo, From 3846bb675c01e862d176bf4d14a49e37d78aae51 Mon Sep 17 00:00:00 2001 From: ndaemy Date: Tue, 14 Feb 2023 03:09:49 +0900 Subject: [PATCH 4/6] =?UTF-8?q?fix:=20Conflict=20=EB=B0=9C=EC=83=9D=20?= =?UTF-8?q?=EC=8B=9C=20500=20=EC=97=90=EB=9F=AC=EA=B0=80=20=ED=84=B0?= =?UTF-8?q?=EC=A7=80=EB=8D=98=20=EA=B2=83=EC=9D=84=20409=20=EC=97=90?= =?UTF-8?q?=EB=9F=AC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/applications/applications.service.ts | 31 +++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/api/applications/applications.service.ts b/src/api/applications/applications.service.ts index 1c9655e..2302b44 100644 --- a/src/api/applications/applications.service.ts +++ b/src/api/applications/applications.service.ts @@ -1,5 +1,9 @@ import { PutObjectCommand } from '@aws-sdk/client-s3'; -import { BadRequestException, HttpException, Injectable } from '@nestjs/common'; +import { + BadRequestException, + ConflictException, + Injectable, +} from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; import { Repository } from 'typeorm'; @@ -17,6 +21,31 @@ export class ApplicationsService { async create(createApplicationDto: CreateApplicationDto) { const { personalInfo, applicationInfo } = createApplicationDto; + const conflictErrors: string[] = []; + const [samePhoneUser] = await this.applicationRepository.findBy({ + phone: personalInfo.phone, + }); + const [sameEmailUser] = await this.applicationRepository.findBy({ + email: personalInfo.email, + }); + const [sameSidUser] = await this.applicationRepository.findBy({ + sid: personalInfo.sid, + }); + + if (samePhoneUser) { + conflictErrors.push(`phone ${personalInfo.phone} is already exist`); + } + if (sameEmailUser) { + conflictErrors.push(`email ${personalInfo.email} is already exist`); + } + if (sameSidUser) { + conflictErrors.push(`sid ${personalInfo.sid} is already exist`); + } + + if (conflictErrors.length > 0) { + throw new ConflictException(conflictErrors); + } + // 디지몬 파트가 아닌데 자기소개서가 없으면 400 에러 if (personalInfo.part !== 'design') { const errors: string[] = []; From 8a788f96237cc9865f9c703d97b9d7653ac4fffe Mon Sep 17 00:00:00 2001 From: ndaemy Date: Wed, 15 Feb 2023 17:32:21 +0900 Subject: [PATCH 5/6] =?UTF-8?q?refactor:=20findBy=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=EB=A5=BC=20findOne=20=EB=A9=94=EC=84=9C=EB=93=9C?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/applications/applications.service.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/api/applications/applications.service.ts b/src/api/applications/applications.service.ts index 2302b44..5e6f456 100644 --- a/src/api/applications/applications.service.ts +++ b/src/api/applications/applications.service.ts @@ -22,14 +22,20 @@ export class ApplicationsService { const { personalInfo, applicationInfo } = createApplicationDto; const conflictErrors: string[] = []; - const [samePhoneUser] = await this.applicationRepository.findBy({ - phone: personalInfo.phone, + const samePhoneUser = await this.applicationRepository.findOne({ + where: { + phone: personalInfo.phone, + }, }); - const [sameEmailUser] = await this.applicationRepository.findBy({ - email: personalInfo.email, + const sameEmailUser = await this.applicationRepository.findOne({ + where: { + email: personalInfo.email, + }, }); - const [sameSidUser] = await this.applicationRepository.findBy({ - sid: personalInfo.sid, + const sameSidUser = await this.applicationRepository.findOne({ + where: { + sid: personalInfo.sid, + }, }); if (samePhoneUser) { From be25f512673251276bbe5423527b30298162acb6 Mon Sep 17 00:00:00 2001 From: ndaemy Date: Wed, 15 Feb 2023 17:33:50 +0900 Subject: [PATCH 6/6] =?UTF-8?q?docs:=20=EC=9E=90=EA=B8=B0=EC=86=8C?= =?UTF-8?q?=EA=B0=9C=EC=84=9C=20=3D>=20=EC=9E=90=EA=B8=B0=EC=86=8C?= =?UTF-8?q?=EA=B0=9C=EC=84=9C=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=EB=A1=9C=20=EC=A3=BC=EC=84=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/applications/applications.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/applications/applications.service.ts b/src/api/applications/applications.service.ts index 5e6f456..d048d4f 100644 --- a/src/api/applications/applications.service.ts +++ b/src/api/applications/applications.service.ts @@ -52,7 +52,7 @@ export class ApplicationsService { throw new ConflictException(conflictErrors); } - // 디지몬 파트가 아닌데 자기소개서가 없으면 400 에러 + // 디지몬 파트가 아닌데 자기소개서 페이지 파일이 없으면 400 에러 if (personalInfo.part !== 'design') { const errors: string[] = [];