From ae24b2ac6cd2a555f5907f850f05dddbdaaf7646 Mon Sep 17 00:00:00 2001 From: cabbage16 Date: Tue, 9 Jul 2024 16:22:25 +0900 Subject: [PATCH 01/25] =?UTF-8?q?feat(#98):=20=EC=B5=9C=EC=A2=85=20?= =?UTF-8?q?=ED=95=A9=EA=B2=A9=20=EC=97=AC=EB=B6=80=20=EA=B2=B0=EC=A0=95=20?= =?UTF-8?q?API=20=EC=9E=91=EC=84=B1=20-=20=EC=96=B4=EB=93=9C=EB=AF=BC?= =?UTF-8?q?=EC=9D=B4=20=EC=B5=9C=EC=A2=85=20=EC=A0=90=EC=88=98=20=EC=88=9C?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=B5=9C=EC=A2=85=20=ED=95=A9=EA=B2=A9=20?= =?UTF-8?q?=EC=97=AC=EB=B6=80=EB=A5=BC=20=EA=B2=B0=EC=A0=95=ED=95=A0=20?= =?UTF-8?q?=EC=88=98=20=EC=9E=88=EC=8A=B5=EB=8B=88=EB=8B=A4.=20-=201?= =?UTF-8?q?=EC=B0=A8=20=ED=95=A9=EA=B2=A9=20=EC=9B=90=EC=84=9C=20=EC=A4=91?= =?UTF-8?q?=20=EC=B5=9C=EC=A2=85=20=EC=A0=90=EC=88=98=EA=B0=80=20=EC=97=86?= =?UTF-8?q?=EB=8A=94=20=EC=9B=90=EC=84=9C=EA=B0=80=20=EC=9E=88=EB=8B=A4?= =?UTF-8?q?=EB=A9=B4=20=EC=98=88=EC=99=B8=EA=B0=80=20=EB=B0=9C=EC=83=9D?= =?UTF-8?q?=ED=95=A9=EB=8B=88=EB=8B=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/SelectFirstPassUseCase.java | 5 + .../form/SelectSecondPassUseCase.java | 101 ++++++++++++++++++ .../exception/TotalScoreMissingException.java | 11 ++ .../exception/error/FormErrorProperty.java | 1 + .../form/FormRepositoryCustom.java | 2 + .../persistence/form/FormRepositoryImpl.java | 37 +++++++ .../presentation/form/FormController.java | 33 ++---- .../shared/variable/AdmissionCapacity.java | 11 ++ 8 files changed, 177 insertions(+), 24 deletions(-) create mode 100644 src/main/java/com/bamdoliro/maru/application/form/SelectSecondPassUseCase.java create mode 100644 src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java create mode 100644 src/main/java/com/bamdoliro/maru/shared/variable/AdmissionCapacity.java diff --git a/src/main/java/com/bamdoliro/maru/application/form/SelectFirstPassUseCase.java b/src/main/java/com/bamdoliro/maru/application/form/SelectFirstPassUseCase.java index 186bfedb..e004d033 100644 --- a/src/main/java/com/bamdoliro/maru/application/form/SelectFirstPassUseCase.java +++ b/src/main/java/com/bamdoliro/maru/application/form/SelectFirstPassUseCase.java @@ -6,6 +6,7 @@ import com.bamdoliro.maru.infrastructure.persistence.form.FormRepository; import com.bamdoliro.maru.shared.annotation.UseCase; import com.bamdoliro.maru.shared.constants.FixedNumber; +import com.bamdoliro.maru.shared.variable.AdmissionCapacity; import lombok.RequiredArgsConstructor; import org.springframework.transaction.annotation.Transactional; @@ -34,12 +35,16 @@ public void execute() { int gap = FixedNumber.MEISTER_TALENT - meisterTalentFormList.size(); regularCount += gap; meisterTalentCount -= gap; + AdmissionCapacity.regular += gap; + AdmissionCapacity.meisterTalent -= gap; } if (socialIntegrationFormList.size() < FixedNumber.SOCIAL_INTEGRATION) { int gap = FixedNumber.SOCIAL_INTEGRATION - socialIntegrationFormList.size(); regularCount += gap; socialIntegrationCount -= gap; + AdmissionCapacity.regular += gap; + AdmissionCapacity.socialIntegration -= gap; } regularCount = calculateMultiple(regularCount); diff --git a/src/main/java/com/bamdoliro/maru/application/form/SelectSecondPassUseCase.java b/src/main/java/com/bamdoliro/maru/application/form/SelectSecondPassUseCase.java new file mode 100644 index 00000000..27382ac9 --- /dev/null +++ b/src/main/java/com/bamdoliro/maru/application/form/SelectSecondPassUseCase.java @@ -0,0 +1,101 @@ +package com.bamdoliro.maru.application.form; + +import com.bamdoliro.maru.domain.form.domain.Form; +import com.bamdoliro.maru.domain.form.domain.type.FormStatus; +import com.bamdoliro.maru.domain.form.domain.type.FormType; +import com.bamdoliro.maru.domain.form.exception.TotalScoreMissingException; +import com.bamdoliro.maru.infrastructure.persistence.form.FormRepository; +import com.bamdoliro.maru.shared.annotation.UseCase; +import com.bamdoliro.maru.shared.constants.FixedNumber; +import com.bamdoliro.maru.shared.variable.AdmissionCapacity; +import jakarta.transaction.Transactional; +import lombok.RequiredArgsConstructor; + +import java.util.List; + +@RequiredArgsConstructor +@UseCase +public class SelectSecondPassUseCase { + + private final FormRepository formRepository; + + @Transactional + public void execute() { + validate(); + + int regularCount = AdmissionCapacity.regular; + int meisterTalentCount = AdmissionCapacity.meisterTalent; + int socialIntegrationCount = AdmissionCapacity.socialIntegration; + int nationalVeteransEducationCount = FixedNumber.NATIONAL_VETERANS_EDUCATION; + int specialAdmissionCount = FixedNumber.SPECIAL_ADMISSION; + int equalOpportunityCount = (int) Math.round(socialIntegrationCount * 0.5); + int societyDiversityCount = equalOpportunityCount; + + List
specialFormList = formRepository.findFirstPassedSpecialForm(); + List meisterTalentFormList = classifyFormsByType(specialFormList, FormType::isMeister); + List socialIntegrationFormList = classifyFormsByType(specialFormList, FormType::isSocial); + + for (Form form : socialIntegrationFormList) { + if (form.getType().isEqualOpportunity() && equalOpportunityCount > 0) { + form.pass(); + equalOpportunityCount--; + } else if (form.getType().isSocietyDiversity() && societyDiversityCount > 0) { + form.pass(); + societyDiversityCount--; + } else { + form.fail(); + } + } + + for (Form form : meisterTalentFormList) { + if (meisterTalentCount > 0) { + form.pass(); + meisterTalentCount--; + } else { + form.fail(); + } + } + + formRepository.flush(); + List regularOrSupernumeraryFormList = formRepository.findFirstPassedRegularOrSupernumeraryForm(); + System.out.println(regularOrSupernumeraryFormList.size()); + + for (Form form : regularOrSupernumeraryFormList) { + if (form.getType().isRegular() && regularCount > 0) { + form.pass(); + regularCount--; + } else if ( + form.getType().isNationalVeteransEducation() && + regularCount > 0 && + nationalVeteransEducationCount > 0 + ) { + form.pass(); + nationalVeteransEducationCount--; + } else if ( + form.getType().isSpecialAdmission() && + regularCount > 0 && + specialAdmissionCount > 0 + ) { + form.pass(); + specialAdmissionCount--; + } else { + form.fail(); + } + } + } + + private void validate() { + List firstPassedFormList = formRepository.findByStatus(FormStatus.FIRST_PASSED); + for (Form form : firstPassedFormList) { + if (form.getScore().getTotalScore() == null) { + throw new TotalScoreMissingException(); + } + } + } + + private List classifyFormsByType(List formList, FormTypeFilter filter) { + return formList.stream() + .filter(form -> filter.execute(form.getType())) + .toList(); + } +} diff --git a/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java b/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java new file mode 100644 index 00000000..028d46ff --- /dev/null +++ b/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java @@ -0,0 +1,11 @@ +package com.bamdoliro.maru.domain.form.exception; + +import com.bamdoliro.maru.domain.form.exception.error.FormErrorProperty; +import com.bamdoliro.maru.shared.error.ErrorProperty; +import com.bamdoliro.maru.shared.error.MaruException; + +public class TotalScoreMissingException extends MaruException { + public TotalScoreMissingException() { + super(FormErrorProperty.TOTAL_SCORE_MISSING); + } +} diff --git a/src/main/java/com/bamdoliro/maru/domain/form/exception/error/FormErrorProperty.java b/src/main/java/com/bamdoliro/maru/domain/form/exception/error/FormErrorProperty.java index 99af1e5f..308798d8 100644 --- a/src/main/java/com/bamdoliro/maru/domain/form/exception/error/FormErrorProperty.java +++ b/src/main/java/com/bamdoliro/maru/domain/form/exception/error/FormErrorProperty.java @@ -15,6 +15,7 @@ public enum FormErrorProperty implements ErrorProperty { CANNOT_UPDATE_NOT_REJECTED_FORM(HttpStatus.CONFLICT, "반려된 원서만 수정할 수 있습니다."), INVALID_FORM_STATUS(HttpStatus.CONFLICT, "원서 상태가 유효하지 않습니다."), INVALID_FILE(HttpStatus.BAD_REQUEST, "잘못된 파일입니다."), + TOTAL_SCORE_MISSING(HttpStatus.PRECONDITION_FAILED, "최종 점수가 입력되지 않은 원서가 존재합니다.") ; private final HttpStatus status; diff --git a/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryCustom.java b/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryCustom.java index 7c2dd0ab..b9d4d51a 100644 --- a/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryCustom.java +++ b/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryCustom.java @@ -11,6 +11,8 @@ public interface FormRepositoryCustom { List findByStatus(FormStatus status); List findReceivedSpecialForm(); List findReceivedRegularOrSupernumeraryForm(); + List findFirstPassedSpecialForm(); + List findFirstPassedRegularOrSupernumeraryForm(); List findFirstRoundForm(); List findMeisterTalentFirstRoundForm(); List findNotExistsMeisterTalentAndChangedToRegularFirstRoundForm(); diff --git a/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryImpl.java b/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryImpl.java index d8cc004e..4c862f67 100644 --- a/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryImpl.java +++ b/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryImpl.java @@ -75,6 +75,43 @@ public List findReceivedRegularOrSupernumeraryForm() { .fetch(); } + @Override + public List findFirstPassedSpecialForm() { + return queryFactory + .selectFrom(form) + .where( + form.status.eq(FormStatus.FIRST_PASSED) + .and( + form.type.eq(FormType.REGULAR).not() + .and(form.type.eq(FormType.NATIONAL_VETERANS_EDUCATION).not()) + .and(form.type.eq(FormType.SPECIAL_ADMISSION).not()) + ) + ) + .orderBy( + form.score.totalScore.desc() + ) + .fetch(); + } + + @Override + public List findFirstPassedRegularOrSupernumeraryForm() { + return queryFactory + .selectFrom(form) + .where( + form.status.eq(FormStatus.FIRST_PASSED) + .and( + form.type.eq(FormType.REGULAR) + .or(form.type.eq(FormType.NATIONAL_VETERANS_EDUCATION)) + .or(form.type.eq(FormType.SPECIAL_ADMISSION)) + .or(form.changedToRegular.isTrue()) + ) + ) + .orderBy( + form.score.totalScore.desc() + ) + .fetch(); + } + @Override public List findFirstRoundForm() { return queryFactory diff --git a/src/main/java/com/bamdoliro/maru/presentation/form/FormController.java b/src/main/java/com/bamdoliro/maru/presentation/form/FormController.java index 85d1dcc0..ad6560e2 100644 --- a/src/main/java/com/bamdoliro/maru/presentation/form/FormController.java +++ b/src/main/java/com/bamdoliro/maru/presentation/form/FormController.java @@ -1,29 +1,6 @@ package com.bamdoliro.maru.presentation.form; -import com.bamdoliro.maru.application.form.ApproveFormUseCase; -import com.bamdoliro.maru.application.form.DownloadSecondRoundScoreFormatUseCase; -import com.bamdoliro.maru.application.form.ExportFinalPassedFormUseCase; -import com.bamdoliro.maru.application.form.ExportFirstRoundResultUseCase; -import com.bamdoliro.maru.application.form.ExportFormUseCase; -import com.bamdoliro.maru.application.form.ExportResultUseCase; -import com.bamdoliro.maru.application.form.ExportSecondRoundResultUseCase; -import com.bamdoliro.maru.application.form.GenerateAdmissionTicketUseCase; -import com.bamdoliro.maru.application.form.PassOrFailFormUseCase; -import com.bamdoliro.maru.application.form.QueryAllFormUseCase; -import com.bamdoliro.maru.application.form.QueryFinalFormResultUseCase; -import com.bamdoliro.maru.application.form.QueryFirstFormResultUseCase; -import com.bamdoliro.maru.application.form.QueryFormStatusUseCase; -import com.bamdoliro.maru.application.form.QueryFormUrlUseCase; -import com.bamdoliro.maru.application.form.QueryFormUseCase; -import com.bamdoliro.maru.application.form.QuerySubmittedFormUseCase; -import com.bamdoliro.maru.application.form.ReceiveFormUseCase; -import com.bamdoliro.maru.application.form.RejectFormUseCase; -import com.bamdoliro.maru.application.form.SubmitFinalFormUseCase; -import com.bamdoliro.maru.application.form.SubmitFormUseCase; -import com.bamdoliro.maru.application.form.UpdateFormUseCase; -import com.bamdoliro.maru.application.form.UpdateSecondRoundScoreUseCase; -import com.bamdoliro.maru.application.form.UploadFormUseCase; -import com.bamdoliro.maru.application.form.UploadIdentificationPictureUseCase; +import com.bamdoliro.maru.application.form.*; import com.bamdoliro.maru.domain.form.domain.type.FormStatus; import com.bamdoliro.maru.domain.form.domain.type.FormType; import com.bamdoliro.maru.domain.user.domain.User; @@ -92,6 +69,7 @@ public class FormController { private final ExportResultUseCase exportResultUseCase; private final PassOrFailFormUseCase passOrFailFormUseCase; private final QueryFormUrlUseCase queryFormUrlUseCase; + private final SelectSecondPassUseCase selectSecondPassUseCase; @ResponseStatus(HttpStatus.CREATED) @PostMapping @@ -320,4 +298,11 @@ public ListCommonResponse getFormUrl( queryFormUrlUseCase.execute(formIdList) ); } + + @PatchMapping("/second-pass") + public void selectSecondPass( + @AuthenticationPrincipal(authority = Authority.ADMIN) User user + ) { + selectSecondPassUseCase.execute(); + } } \ No newline at end of file diff --git a/src/main/java/com/bamdoliro/maru/shared/variable/AdmissionCapacity.java b/src/main/java/com/bamdoliro/maru/shared/variable/AdmissionCapacity.java new file mode 100644 index 00000000..4e87bb11 --- /dev/null +++ b/src/main/java/com/bamdoliro/maru/shared/variable/AdmissionCapacity.java @@ -0,0 +1,11 @@ +package com.bamdoliro.maru.shared.variable; + +import lombok.experimental.UtilityClass; + +@UtilityClass +public class AdmissionCapacity { + + public static int regular = 36; + public static int meisterTalent = 25; + public static int socialIntegration = 3; +} From 8b2ca5ac72c0964eca08e087b6273cd22d0e3ca9 Mon Sep 17 00:00:00 2001 From: cabbage16 Date: Tue, 9 Jul 2024 16:23:03 +0900 Subject: [PATCH 02/25] =?UTF-8?q?refactor(#98):=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20import=20=EB=AC=B8=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../maru/domain/form/exception/TotalScoreMissingException.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java b/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java index 028d46ff..22557233 100644 --- a/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java +++ b/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java @@ -1,7 +1,6 @@ package com.bamdoliro.maru.domain.form.exception; import com.bamdoliro.maru.domain.form.exception.error.FormErrorProperty; -import com.bamdoliro.maru.shared.error.ErrorProperty; import com.bamdoliro.maru.shared.error.MaruException; public class TotalScoreMissingException extends MaruException { From a8edacc3dde484c0963c84738bb78cd4f829d1ee Mon Sep 17 00:00:00 2001 From: cabbage16 Date: Tue, 9 Jul 2024 16:22:25 +0900 Subject: [PATCH 03/25] =?UTF-8?q?feat(#98):=20=EC=B5=9C=EC=A2=85=20?= =?UTF-8?q?=ED=95=A9=EA=B2=A9=20=EC=97=AC=EB=B6=80=20=EA=B2=B0=EC=A0=95=20?= =?UTF-8?q?API=20=EC=9E=91=EC=84=B1=20-=20=EC=96=B4=EB=93=9C=EB=AF=BC?= =?UTF-8?q?=EC=9D=B4=20=EC=B5=9C=EC=A2=85=20=EC=A0=90=EC=88=98=20=EC=88=9C?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=B5=9C=EC=A2=85=20=ED=95=A9=EA=B2=A9=20?= =?UTF-8?q?=EC=97=AC=EB=B6=80=EB=A5=BC=20=EA=B2=B0=EC=A0=95=ED=95=A0=20?= =?UTF-8?q?=EC=88=98=20=EC=9E=88=EC=8A=B5=EB=8B=88=EB=8B=A4.=20-=201?= =?UTF-8?q?=EC=B0=A8=20=ED=95=A9=EA=B2=A9=20=EC=9B=90=EC=84=9C=20=EC=A4=91?= =?UTF-8?q?=20=EC=B5=9C=EC=A2=85=20=EC=A0=90=EC=88=98=EA=B0=80=20=EC=97=86?= =?UTF-8?q?=EB=8A=94=20=EC=9B=90=EC=84=9C=EA=B0=80=20=EC=9E=88=EB=8B=A4?= =?UTF-8?q?=EB=A9=B4=20=EC=98=88=EC=99=B8=EA=B0=80=20=EB=B0=9C=EC=83=9D?= =?UTF-8?q?=ED=95=A9=EB=8B=88=EB=8B=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/SelectFirstPassUseCase.java | 5 + .../form/SelectSecondPassUseCase.java | 101 ++++++++++++++++++ .../exception/TotalScoreMissingException.java | 11 ++ .../exception/error/FormErrorProperty.java | 1 + .../form/FormRepositoryCustom.java | 2 + .../persistence/form/FormRepositoryImpl.java | 37 +++++++ .../presentation/form/FormController.java | 33 ++---- .../shared/variable/AdmissionCapacity.java | 11 ++ 8 files changed, 177 insertions(+), 24 deletions(-) create mode 100644 src/main/java/com/bamdoliro/maru/application/form/SelectSecondPassUseCase.java create mode 100644 src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java create mode 100644 src/main/java/com/bamdoliro/maru/shared/variable/AdmissionCapacity.java diff --git a/src/main/java/com/bamdoliro/maru/application/form/SelectFirstPassUseCase.java b/src/main/java/com/bamdoliro/maru/application/form/SelectFirstPassUseCase.java index 186bfedb..e004d033 100644 --- a/src/main/java/com/bamdoliro/maru/application/form/SelectFirstPassUseCase.java +++ b/src/main/java/com/bamdoliro/maru/application/form/SelectFirstPassUseCase.java @@ -6,6 +6,7 @@ import com.bamdoliro.maru.infrastructure.persistence.form.FormRepository; import com.bamdoliro.maru.shared.annotation.UseCase; import com.bamdoliro.maru.shared.constants.FixedNumber; +import com.bamdoliro.maru.shared.variable.AdmissionCapacity; import lombok.RequiredArgsConstructor; import org.springframework.transaction.annotation.Transactional; @@ -34,12 +35,16 @@ public void execute() { int gap = FixedNumber.MEISTER_TALENT - meisterTalentFormList.size(); regularCount += gap; meisterTalentCount -= gap; + AdmissionCapacity.regular += gap; + AdmissionCapacity.meisterTalent -= gap; } if (socialIntegrationFormList.size() < FixedNumber.SOCIAL_INTEGRATION) { int gap = FixedNumber.SOCIAL_INTEGRATION - socialIntegrationFormList.size(); regularCount += gap; socialIntegrationCount -= gap; + AdmissionCapacity.regular += gap; + AdmissionCapacity.socialIntegration -= gap; } regularCount = calculateMultiple(regularCount); diff --git a/src/main/java/com/bamdoliro/maru/application/form/SelectSecondPassUseCase.java b/src/main/java/com/bamdoliro/maru/application/form/SelectSecondPassUseCase.java new file mode 100644 index 00000000..27382ac9 --- /dev/null +++ b/src/main/java/com/bamdoliro/maru/application/form/SelectSecondPassUseCase.java @@ -0,0 +1,101 @@ +package com.bamdoliro.maru.application.form; + +import com.bamdoliro.maru.domain.form.domain.Form; +import com.bamdoliro.maru.domain.form.domain.type.FormStatus; +import com.bamdoliro.maru.domain.form.domain.type.FormType; +import com.bamdoliro.maru.domain.form.exception.TotalScoreMissingException; +import com.bamdoliro.maru.infrastructure.persistence.form.FormRepository; +import com.bamdoliro.maru.shared.annotation.UseCase; +import com.bamdoliro.maru.shared.constants.FixedNumber; +import com.bamdoliro.maru.shared.variable.AdmissionCapacity; +import jakarta.transaction.Transactional; +import lombok.RequiredArgsConstructor; + +import java.util.List; + +@RequiredArgsConstructor +@UseCase +public class SelectSecondPassUseCase { + + private final FormRepository formRepository; + + @Transactional + public void execute() { + validate(); + + int regularCount = AdmissionCapacity.regular; + int meisterTalentCount = AdmissionCapacity.meisterTalent; + int socialIntegrationCount = AdmissionCapacity.socialIntegration; + int nationalVeteransEducationCount = FixedNumber.NATIONAL_VETERANS_EDUCATION; + int specialAdmissionCount = FixedNumber.SPECIAL_ADMISSION; + int equalOpportunityCount = (int) Math.round(socialIntegrationCount * 0.5); + int societyDiversityCount = equalOpportunityCount; + + List specialFormList = formRepository.findFirstPassedSpecialForm(); + List meisterTalentFormList = classifyFormsByType(specialFormList, FormType::isMeister); + List socialIntegrationFormList = classifyFormsByType(specialFormList, FormType::isSocial); + + for (Form form : socialIntegrationFormList) { + if (form.getType().isEqualOpportunity() && equalOpportunityCount > 0) { + form.pass(); + equalOpportunityCount--; + } else if (form.getType().isSocietyDiversity() && societyDiversityCount > 0) { + form.pass(); + societyDiversityCount--; + } else { + form.fail(); + } + } + + for (Form form : meisterTalentFormList) { + if (meisterTalentCount > 0) { + form.pass(); + meisterTalentCount--; + } else { + form.fail(); + } + } + + formRepository.flush(); + List regularOrSupernumeraryFormList = formRepository.findFirstPassedRegularOrSupernumeraryForm(); + System.out.println(regularOrSupernumeraryFormList.size()); + + for (Form form : regularOrSupernumeraryFormList) { + if (form.getType().isRegular() && regularCount > 0) { + form.pass(); + regularCount--; + } else if ( + form.getType().isNationalVeteransEducation() && + regularCount > 0 && + nationalVeteransEducationCount > 0 + ) { + form.pass(); + nationalVeteransEducationCount--; + } else if ( + form.getType().isSpecialAdmission() && + regularCount > 0 && + specialAdmissionCount > 0 + ) { + form.pass(); + specialAdmissionCount--; + } else { + form.fail(); + } + } + } + + private void validate() { + List firstPassedFormList = formRepository.findByStatus(FormStatus.FIRST_PASSED); + for (Form form : firstPassedFormList) { + if (form.getScore().getTotalScore() == null) { + throw new TotalScoreMissingException(); + } + } + } + + private List classifyFormsByType(List formList, FormTypeFilter filter) { + return formList.stream() + .filter(form -> filter.execute(form.getType())) + .toList(); + } +} diff --git a/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java b/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java new file mode 100644 index 00000000..028d46ff --- /dev/null +++ b/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java @@ -0,0 +1,11 @@ +package com.bamdoliro.maru.domain.form.exception; + +import com.bamdoliro.maru.domain.form.exception.error.FormErrorProperty; +import com.bamdoliro.maru.shared.error.ErrorProperty; +import com.bamdoliro.maru.shared.error.MaruException; + +public class TotalScoreMissingException extends MaruException { + public TotalScoreMissingException() { + super(FormErrorProperty.TOTAL_SCORE_MISSING); + } +} diff --git a/src/main/java/com/bamdoliro/maru/domain/form/exception/error/FormErrorProperty.java b/src/main/java/com/bamdoliro/maru/domain/form/exception/error/FormErrorProperty.java index 99af1e5f..308798d8 100644 --- a/src/main/java/com/bamdoliro/maru/domain/form/exception/error/FormErrorProperty.java +++ b/src/main/java/com/bamdoliro/maru/domain/form/exception/error/FormErrorProperty.java @@ -15,6 +15,7 @@ public enum FormErrorProperty implements ErrorProperty { CANNOT_UPDATE_NOT_REJECTED_FORM(HttpStatus.CONFLICT, "반려된 원서만 수정할 수 있습니다."), INVALID_FORM_STATUS(HttpStatus.CONFLICT, "원서 상태가 유효하지 않습니다."), INVALID_FILE(HttpStatus.BAD_REQUEST, "잘못된 파일입니다."), + TOTAL_SCORE_MISSING(HttpStatus.PRECONDITION_FAILED, "최종 점수가 입력되지 않은 원서가 존재합니다.") ; private final HttpStatus status; diff --git a/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryCustom.java b/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryCustom.java index 4f9cbe87..85a946cb 100644 --- a/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryCustom.java +++ b/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryCustom.java @@ -17,6 +17,8 @@ public interface FormRepositoryCustom { List findByCategory(FormType.Category category); List findReceivedSpecialForm(); List findReceivedRegularOrSupernumeraryForm(); + List findFirstPassedSpecialForm(); + List findFirstPassedRegularOrSupernumeraryForm(); List findFirstRoundForm(); List findMeisterTalentFirstRoundForm(); List findNotExistsMeisterTalentAndChangedToRegularFirstRoundForm(); diff --git a/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryImpl.java b/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryImpl.java index 5a09b03f..b1dbae5d 100644 --- a/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryImpl.java +++ b/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryImpl.java @@ -109,6 +109,43 @@ public List findReceivedRegularOrSupernumeraryForm() { .fetch(); } + @Override + public List findFirstPassedSpecialForm() { + return queryFactory + .selectFrom(form) + .where( + form.status.eq(FormStatus.FIRST_PASSED) + .and( + form.type.eq(FormType.REGULAR).not() + .and(form.type.eq(FormType.NATIONAL_VETERANS_EDUCATION).not()) + .and(form.type.eq(FormType.SPECIAL_ADMISSION).not()) + ) + ) + .orderBy( + form.score.totalScore.desc() + ) + .fetch(); + } + + @Override + public List findFirstPassedRegularOrSupernumeraryForm() { + return queryFactory + .selectFrom(form) + .where( + form.status.eq(FormStatus.FIRST_PASSED) + .and( + form.type.eq(FormType.REGULAR) + .or(form.type.eq(FormType.NATIONAL_VETERANS_EDUCATION)) + .or(form.type.eq(FormType.SPECIAL_ADMISSION)) + .or(form.changedToRegular.isTrue()) + ) + ) + .orderBy( + form.score.totalScore.desc() + ) + .fetch(); + } + @Override public List findFirstRoundForm() { return queryFactory diff --git a/src/main/java/com/bamdoliro/maru/presentation/form/FormController.java b/src/main/java/com/bamdoliro/maru/presentation/form/FormController.java index 85d1dcc0..ad6560e2 100644 --- a/src/main/java/com/bamdoliro/maru/presentation/form/FormController.java +++ b/src/main/java/com/bamdoliro/maru/presentation/form/FormController.java @@ -1,29 +1,6 @@ package com.bamdoliro.maru.presentation.form; -import com.bamdoliro.maru.application.form.ApproveFormUseCase; -import com.bamdoliro.maru.application.form.DownloadSecondRoundScoreFormatUseCase; -import com.bamdoliro.maru.application.form.ExportFinalPassedFormUseCase; -import com.bamdoliro.maru.application.form.ExportFirstRoundResultUseCase; -import com.bamdoliro.maru.application.form.ExportFormUseCase; -import com.bamdoliro.maru.application.form.ExportResultUseCase; -import com.bamdoliro.maru.application.form.ExportSecondRoundResultUseCase; -import com.bamdoliro.maru.application.form.GenerateAdmissionTicketUseCase; -import com.bamdoliro.maru.application.form.PassOrFailFormUseCase; -import com.bamdoliro.maru.application.form.QueryAllFormUseCase; -import com.bamdoliro.maru.application.form.QueryFinalFormResultUseCase; -import com.bamdoliro.maru.application.form.QueryFirstFormResultUseCase; -import com.bamdoliro.maru.application.form.QueryFormStatusUseCase; -import com.bamdoliro.maru.application.form.QueryFormUrlUseCase; -import com.bamdoliro.maru.application.form.QueryFormUseCase; -import com.bamdoliro.maru.application.form.QuerySubmittedFormUseCase; -import com.bamdoliro.maru.application.form.ReceiveFormUseCase; -import com.bamdoliro.maru.application.form.RejectFormUseCase; -import com.bamdoliro.maru.application.form.SubmitFinalFormUseCase; -import com.bamdoliro.maru.application.form.SubmitFormUseCase; -import com.bamdoliro.maru.application.form.UpdateFormUseCase; -import com.bamdoliro.maru.application.form.UpdateSecondRoundScoreUseCase; -import com.bamdoliro.maru.application.form.UploadFormUseCase; -import com.bamdoliro.maru.application.form.UploadIdentificationPictureUseCase; +import com.bamdoliro.maru.application.form.*; import com.bamdoliro.maru.domain.form.domain.type.FormStatus; import com.bamdoliro.maru.domain.form.domain.type.FormType; import com.bamdoliro.maru.domain.user.domain.User; @@ -92,6 +69,7 @@ public class FormController { private final ExportResultUseCase exportResultUseCase; private final PassOrFailFormUseCase passOrFailFormUseCase; private final QueryFormUrlUseCase queryFormUrlUseCase; + private final SelectSecondPassUseCase selectSecondPassUseCase; @ResponseStatus(HttpStatus.CREATED) @PostMapping @@ -320,4 +298,11 @@ public ListCommonResponse getFormUrl( queryFormUrlUseCase.execute(formIdList) ); } + + @PatchMapping("/second-pass") + public void selectSecondPass( + @AuthenticationPrincipal(authority = Authority.ADMIN) User user + ) { + selectSecondPassUseCase.execute(); + } } \ No newline at end of file diff --git a/src/main/java/com/bamdoliro/maru/shared/variable/AdmissionCapacity.java b/src/main/java/com/bamdoliro/maru/shared/variable/AdmissionCapacity.java new file mode 100644 index 00000000..4e87bb11 --- /dev/null +++ b/src/main/java/com/bamdoliro/maru/shared/variable/AdmissionCapacity.java @@ -0,0 +1,11 @@ +package com.bamdoliro.maru.shared.variable; + +import lombok.experimental.UtilityClass; + +@UtilityClass +public class AdmissionCapacity { + + public static int regular = 36; + public static int meisterTalent = 25; + public static int socialIntegration = 3; +} From 0e2e76cdd866da44c49a6816a31d6cbbc604abb3 Mon Sep 17 00:00:00 2001 From: cabbage16 Date: Tue, 9 Jul 2024 16:23:03 +0900 Subject: [PATCH 04/25] =?UTF-8?q?refactor(#98):=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20import=20=EB=AC=B8=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../maru/domain/form/exception/TotalScoreMissingException.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java b/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java index 028d46ff..22557233 100644 --- a/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java +++ b/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java @@ -1,7 +1,6 @@ package com.bamdoliro.maru.domain.form.exception; import com.bamdoliro.maru.domain.form.exception.error.FormErrorProperty; -import com.bamdoliro.maru.shared.error.ErrorProperty; import com.bamdoliro.maru.shared.error.MaruException; public class TotalScoreMissingException extends MaruException { From 0797fc7e4cb69eba5a833883fd45807d41ffe5ad Mon Sep 17 00:00:00 2001 From: cabbage16 Date: Wed, 10 Jul 2024 08:22:13 +0900 Subject: [PATCH 05/25] =?UTF-8?q?refactor(#98):=20=EC=98=88=EC=99=B8=20?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=20=EC=88=98=EC=A0=95=20-=20=EC=9E=98?= =?UTF-8?q?=EB=AA=BB=EB=90=9C=20=EC=9D=B4=EB=A6=84=EC=9D=84=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=ED=95=98=EA=B3=A0=20=EC=A2=80=20=EB=8D=94=20=EC=9D=98?= =?UTF-8?q?=EB=AF=B8=EC=97=90=20=EB=A7=9E=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=ED=96=88=EC=8A=B5=EB=8B=88=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/form/GenerateAdmissionTicketUseCase.java | 4 ++-- ...StatusException.java => InvalidFormStatusException.java} | 4 ++-- ...issingException.java => MissingTotalScoreException.java} | 4 ++-- .../form/GenerateAdmissionTicketUseCaseTest.java | 6 ++---- .../maru/presentation/form/FormControllerTest.java | 4 ++-- 5 files changed, 10 insertions(+), 12 deletions(-) rename src/main/java/com/bamdoliro/maru/domain/form/exception/{InvalidFromStatusException.java => InvalidFormStatusException.java} (69%) rename src/main/java/com/bamdoliro/maru/domain/form/exception/{TotalScoreMissingException.java => MissingTotalScoreException.java} (69%) diff --git a/src/main/java/com/bamdoliro/maru/application/form/GenerateAdmissionTicketUseCase.java b/src/main/java/com/bamdoliro/maru/application/form/GenerateAdmissionTicketUseCase.java index 5e9c071f..9022082d 100644 --- a/src/main/java/com/bamdoliro/maru/application/form/GenerateAdmissionTicketUseCase.java +++ b/src/main/java/com/bamdoliro/maru/application/form/GenerateAdmissionTicketUseCase.java @@ -1,7 +1,7 @@ package com.bamdoliro.maru.application.form; import com.bamdoliro.maru.domain.form.domain.Form; -import com.bamdoliro.maru.domain.form.exception.InvalidFromStatusException; +import com.bamdoliro.maru.domain.form.exception.InvalidFormStatusException; import com.bamdoliro.maru.domain.form.service.FormFacade; import com.bamdoliro.maru.domain.user.domain.User; import com.bamdoliro.maru.infrastructure.pdf.GeneratePdfService; @@ -48,7 +48,7 @@ public ByteArrayResource execute(User user) { private void validateFormStatus(Form form) { if (!form.isFirstPassedNow()) { - throw new InvalidFromStatusException(); + throw new InvalidFormStatusException(); } } } diff --git a/src/main/java/com/bamdoliro/maru/domain/form/exception/InvalidFromStatusException.java b/src/main/java/com/bamdoliro/maru/domain/form/exception/InvalidFormStatusException.java similarity index 69% rename from src/main/java/com/bamdoliro/maru/domain/form/exception/InvalidFromStatusException.java rename to src/main/java/com/bamdoliro/maru/domain/form/exception/InvalidFormStatusException.java index 7ac0e431..8e4e990e 100644 --- a/src/main/java/com/bamdoliro/maru/domain/form/exception/InvalidFromStatusException.java +++ b/src/main/java/com/bamdoliro/maru/domain/form/exception/InvalidFormStatusException.java @@ -3,9 +3,9 @@ import com.bamdoliro.maru.domain.form.exception.error.FormErrorProperty; import com.bamdoliro.maru.shared.error.MaruException; -public class InvalidFromStatusException extends MaruException { +public class InvalidFormStatusException extends MaruException { - public InvalidFromStatusException() { + public InvalidFormStatusException() { super(FormErrorProperty.INVALID_FORM_STATUS); } } diff --git a/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java b/src/main/java/com/bamdoliro/maru/domain/form/exception/MissingTotalScoreException.java similarity index 69% rename from src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java rename to src/main/java/com/bamdoliro/maru/domain/form/exception/MissingTotalScoreException.java index 22557233..260beb7e 100644 --- a/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java +++ b/src/main/java/com/bamdoliro/maru/domain/form/exception/MissingTotalScoreException.java @@ -3,8 +3,8 @@ import com.bamdoliro.maru.domain.form.exception.error.FormErrorProperty; import com.bamdoliro.maru.shared.error.MaruException; -public class TotalScoreMissingException extends MaruException { - public TotalScoreMissingException() { +public class MissingTotalScoreException extends MaruException { + public MissingTotalScoreException() { super(FormErrorProperty.TOTAL_SCORE_MISSING); } } diff --git a/src/test/java/com/bamdoliro/maru/application/form/GenerateAdmissionTicketUseCaseTest.java b/src/test/java/com/bamdoliro/maru/application/form/GenerateAdmissionTicketUseCaseTest.java index a23ad2e6..8b0cb7b6 100644 --- a/src/test/java/com/bamdoliro/maru/application/form/GenerateAdmissionTicketUseCaseTest.java +++ b/src/test/java/com/bamdoliro/maru/application/form/GenerateAdmissionTicketUseCaseTest.java @@ -3,12 +3,11 @@ import com.bamdoliro.maru.domain.form.domain.Form; import com.bamdoliro.maru.domain.form.domain.type.FormType; import com.bamdoliro.maru.domain.form.exception.FormNotFoundException; -import com.bamdoliro.maru.domain.form.exception.InvalidFromStatusException; +import com.bamdoliro.maru.domain.form.exception.InvalidFormStatusException; import com.bamdoliro.maru.domain.form.service.FormFacade; import com.bamdoliro.maru.domain.user.domain.User; import com.bamdoliro.maru.infrastructure.pdf.GeneratePdfService; import com.bamdoliro.maru.infrastructure.thymeleaf.ProcessTemplateService; -import com.bamdoliro.maru.infrastructure.thymeleaf.Templates; import com.bamdoliro.maru.shared.fixture.FormFixture; import com.bamdoliro.maru.shared.fixture.UserFixture; import org.junit.jupiter.api.Test; @@ -22,7 +21,6 @@ import static org.junit.jupiter.api.Assertions.*; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.willThrow; import static org.mockito.Mockito.never; @@ -71,7 +69,7 @@ class GenerateAdmissionTicketUseCaseTest { given(formFacade.getForm(user)).willReturn(form); // when and then - assertThrows(InvalidFromStatusException.class, () -> generateAdmissionTicketUseCase.execute(user)); + assertThrows(InvalidFormStatusException.class, () -> generateAdmissionTicketUseCase.execute(user)); verify(formFacade, times(1)).getForm(user); verify(processTemplateService, never()).execute(any(String.class), any(Map.class)); diff --git a/src/test/java/com/bamdoliro/maru/presentation/form/FormControllerTest.java b/src/test/java/com/bamdoliro/maru/presentation/form/FormControllerTest.java index 17720d9a..e788d4ba 100644 --- a/src/test/java/com/bamdoliro/maru/presentation/form/FormControllerTest.java +++ b/src/test/java/com/bamdoliro/maru/presentation/form/FormControllerTest.java @@ -8,7 +8,7 @@ import com.bamdoliro.maru.domain.form.exception.FormAlreadySubmittedException; import com.bamdoliro.maru.domain.form.exception.FormNotFoundException; import com.bamdoliro.maru.domain.form.exception.InvalidFileException; -import com.bamdoliro.maru.domain.form.exception.InvalidFromStatusException; +import com.bamdoliro.maru.domain.form.exception.InvalidFormStatusException; import com.bamdoliro.maru.domain.user.domain.User; import com.bamdoliro.maru.infrastructure.pdf.exception.FailedToExportPdfException; import com.bamdoliro.maru.infrastructure.s3.dto.response.UploadResponse; @@ -1510,7 +1510,7 @@ class FormControllerTest extends RestDocsTestSupport { given(authenticationArgumentResolver.supportsParameter(any(MethodParameter.class))).willReturn(true); given(authenticationArgumentResolver.resolveArgument(any(), any(), any(), any())).willReturn(user); - willThrow(new InvalidFromStatusException()).given(generateAdmissionTicketUseCase).execute(user); + willThrow(new InvalidFormStatusException()).given(generateAdmissionTicketUseCase).execute(user); mockMvc.perform(get("/form/admission-ticket") .header(HttpHeaders.AUTHORIZATION, AuthFixture.createAuthHeader()) From b2a3cc1ddb64e38861ea982e4a41adb244b618c3 Mon Sep 17 00:00:00 2001 From: cabbage16 Date: Wed, 10 Jul 2024 08:24:46 +0900 Subject: [PATCH 06/25] =?UTF-8?q?perf(#98):=20=EC=A0=95=EC=9B=90=20?= =?UTF-8?q?=EC=99=B8=20=EC=A0=84=ED=98=95=EC=9D=B4=20=EB=8B=A4=EB=A5=B8=20?= =?UTF-8?q?=EC=A0=84=ED=98=95=EA=B3=BC=20=EB=8F=85=EB=A6=BD=ED=95=98?= =?UTF-8?q?=EC=97=AC=20=EA=B2=BD=EC=9F=81=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20-=20=EC=A0=95=EC=9B=90=20=EC=99=B8=20?= =?UTF-8?q?=EC=A0=84=ED=98=95=EC=9D=80=20=EB=8B=A4=EB=A5=B8=20=EC=A0=84?= =?UTF-8?q?=ED=98=95=EB=93=A4=EA=B3=BC=20=ED=95=A8=EA=BB=98=20=EA=B2=BD?= =?UTF-8?q?=EC=9F=81=ED=95=98=EC=A7=80=20=EC=95=8A=EA=B3=A0=20=EC=99=84?= =?UTF-8?q?=EC=A0=84=ED=9E=88=20=EB=8F=85=EB=A6=BD=EB=90=98=EC=96=B4=20?= =?UTF-8?q?=EA=B2=BD=EC=9F=81=ED=95=B4=EC=95=BC=ED=95=98=EC=97=AC=EC=84=9C?= =?UTF-8?q?=20=EC=88=98=EC=A0=95=ED=96=88=EC=8A=B5=EB=8B=88=EB=8B=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/SelectFirstPassUseCase.java | 17 ++++++--- .../form/SelectSecondPassUseCase.java | 38 +++++++++---------- .../form/FormRepositoryCustom.java | 6 ++- .../persistence/form/FormRepositoryImpl.java | 35 ++++++++++++++--- .../presentation/form/FormController.java | 3 +- .../shared/variable/AdmissionCapacity.java | 7 ++-- 6 files changed, 69 insertions(+), 37 deletions(-) diff --git a/src/main/java/com/bamdoliro/maru/application/form/SelectFirstPassUseCase.java b/src/main/java/com/bamdoliro/maru/application/form/SelectFirstPassUseCase.java index e004d033..c7fe7508 100644 --- a/src/main/java/com/bamdoliro/maru/application/form/SelectFirstPassUseCase.java +++ b/src/main/java/com/bamdoliro/maru/application/form/SelectFirstPassUseCase.java @@ -78,22 +78,29 @@ public void execute() { } formRepository.flush(); - List regularOrSupernumeraryFormList = formRepository.findReceivedRegularOrSupernumeraryForm(); + List regularOrSupernumeraryFormList = formRepository.findReceivedRegularForm(); for (Form form : regularOrSupernumeraryFormList) { - if (form.getType().isRegular() && regularCount > 0) { + if (regularCount > 0) { form.firstPass(); regularCount--; - } else if ( + } else { + form.firstFail(); + } + } + + formRepository.flush(); + List supernumeraryFormList = formRepository.findReceivedSupernumeraryForm(); + + for (Form form : supernumeraryFormList) { + if ( form.getType().isNationalVeteransEducation() && - regularCount > 0 && nationalVeteransEducationCount > 0 ) { form.firstPass(); nationalVeteransEducationCount--; } else if ( form.getType().isSpecialAdmission() && - regularCount > 0 && specialAdmissionCount > 0 ) { form.firstPass(); diff --git a/src/main/java/com/bamdoliro/maru/application/form/SelectSecondPassUseCase.java b/src/main/java/com/bamdoliro/maru/application/form/SelectSecondPassUseCase.java index 27382ac9..1eef48f4 100644 --- a/src/main/java/com/bamdoliro/maru/application/form/SelectSecondPassUseCase.java +++ b/src/main/java/com/bamdoliro/maru/application/form/SelectSecondPassUseCase.java @@ -3,7 +3,7 @@ import com.bamdoliro.maru.domain.form.domain.Form; import com.bamdoliro.maru.domain.form.domain.type.FormStatus; import com.bamdoliro.maru.domain.form.domain.type.FormType; -import com.bamdoliro.maru.domain.form.exception.TotalScoreMissingException; +import com.bamdoliro.maru.domain.form.exception.MissingTotalScoreException; import com.bamdoliro.maru.infrastructure.persistence.form.FormRepository; import com.bamdoliro.maru.shared.annotation.UseCase; import com.bamdoliro.maru.shared.constants.FixedNumber; @@ -57,25 +57,25 @@ public void execute() { } formRepository.flush(); - List regularOrSupernumeraryFormList = formRepository.findFirstPassedRegularOrSupernumeraryForm(); - System.out.println(regularOrSupernumeraryFormList.size()); + List regularFormList = formRepository.findFirstPassedRegularForm(); - for (Form form : regularOrSupernumeraryFormList) { - if (form.getType().isRegular() && regularCount > 0) { + for (Form form : regularFormList) { + if (regularCount > 0) { form.pass(); regularCount--; - } else if ( - form.getType().isNationalVeteransEducation() && - regularCount > 0 && - nationalVeteransEducationCount > 0 - ) { + } else { + form.fail(); + } + } + + formRepository.flush(); + List supernumeraryFormList = formRepository.findFirstPassedSupernumeraryForm(); + + for (Form form : supernumeraryFormList) { + if (form.getType().isNationalVeteransEducation() && nationalVeteransEducationCount > 0) { form.pass(); nationalVeteransEducationCount--; - } else if ( - form.getType().isSpecialAdmission() && - regularCount > 0 && - specialAdmissionCount > 0 - ) { + } else if (form.getType().isSpecialAdmission() && specialAdmissionCount > 0) { form.pass(); specialAdmissionCount--; } else { @@ -86,11 +86,9 @@ public void execute() { private void validate() { List firstPassedFormList = formRepository.findByStatus(FormStatus.FIRST_PASSED); - for (Form form : firstPassedFormList) { - if (form.getScore().getTotalScore() == null) { - throw new TotalScoreMissingException(); - } - } + firstPassedFormList.stream() + .filter(form -> form.getScore().getTotalScore() == null) + .forEach(form -> {throw new MissingTotalScoreException();}); } private List classifyFormsByType(List formList, FormTypeFilter filter) { diff --git a/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryCustom.java b/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryCustom.java index 85a946cb..eb7702cb 100644 --- a/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryCustom.java +++ b/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryCustom.java @@ -16,9 +16,11 @@ public interface FormRepositoryCustom { List findByType(FormType type); List findByCategory(FormType.Category category); List findReceivedSpecialForm(); - List findReceivedRegularOrSupernumeraryForm(); + List findReceivedRegularForm(); + List findReceivedSupernumeraryForm(); List findFirstPassedSpecialForm(); - List findFirstPassedRegularOrSupernumeraryForm(); + List findFirstPassedRegularForm(); + List findFirstPassedSupernumeraryForm(); List findFirstRoundForm(); List findMeisterTalentFirstRoundForm(); List findNotExistsMeisterTalentAndChangedToRegularFirstRoundForm(); diff --git a/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryImpl.java b/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryImpl.java index b1dbae5d..de309458 100644 --- a/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryImpl.java +++ b/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryImpl.java @@ -91,15 +91,13 @@ public List findReceivedSpecialForm() { } @Override - public List findReceivedRegularOrSupernumeraryForm() { + public List findReceivedRegularForm() { return queryFactory .selectFrom(form) .where( form.status.eq(FormStatus.RECEIVED) .and( form.type.eq(FormType.REGULAR) - .or(form.type.eq(FormType.NATIONAL_VETERANS_EDUCATION)) - .or(form.type.eq(FormType.SPECIAL_ADMISSION)) .or(form.changedToRegular.isTrue()) ) ) @@ -109,6 +107,23 @@ public List findReceivedRegularOrSupernumeraryForm() { .fetch(); } + @Override + public List findReceivedSupernumeraryForm() { + return queryFactory + .selectFrom(form) + .where( + form.status.eq(FormStatus.RECEIVED) + .and( + form.type.eq(FormType.SPECIAL_ADMISSION) + .or(form.type.eq(FormType.NATIONAL_VETERANS_EDUCATION)) + ) + ) + .orderBy( + form.score.firstRoundScore.desc() + ) + .fetch(); + } + @Override public List findFirstPassedSpecialForm() { return queryFactory @@ -128,15 +143,13 @@ public List findFirstPassedSpecialForm() { } @Override - public List findFirstPassedRegularOrSupernumeraryForm() { + public List findFirstPassedRegularForm() { return queryFactory .selectFrom(form) .where( form.status.eq(FormStatus.FIRST_PASSED) .and( form.type.eq(FormType.REGULAR) - .or(form.type.eq(FormType.NATIONAL_VETERANS_EDUCATION)) - .or(form.type.eq(FormType.SPECIAL_ADMISSION)) .or(form.changedToRegular.isTrue()) ) ) @@ -146,6 +159,16 @@ public List findFirstPassedRegularOrSupernumeraryForm() { .fetch(); } + @Override + public List findFirstPassedSupernumeraryForm() { + return List.of(); + } + +// @Override +// public List findFirstPassedRegularOrSupernumeraryForm() { +// +// } + @Override public List findFirstRoundForm() { return queryFactory diff --git a/src/main/java/com/bamdoliro/maru/presentation/form/FormController.java b/src/main/java/com/bamdoliro/maru/presentation/form/FormController.java index ad6560e2..5983885c 100644 --- a/src/main/java/com/bamdoliro/maru/presentation/form/FormController.java +++ b/src/main/java/com/bamdoliro/maru/presentation/form/FormController.java @@ -299,7 +299,8 @@ public ListCommonResponse getFormUrl( ); } - @PatchMapping("/second-pass") + @ResponseStatus(HttpStatus.NO_CONTENT) + @PatchMapping("/second-round/select") public void selectSecondPass( @AuthenticationPrincipal(authority = Authority.ADMIN) User user ) { diff --git a/src/main/java/com/bamdoliro/maru/shared/variable/AdmissionCapacity.java b/src/main/java/com/bamdoliro/maru/shared/variable/AdmissionCapacity.java index 4e87bb11..15266c5d 100644 --- a/src/main/java/com/bamdoliro/maru/shared/variable/AdmissionCapacity.java +++ b/src/main/java/com/bamdoliro/maru/shared/variable/AdmissionCapacity.java @@ -1,11 +1,12 @@ package com.bamdoliro.maru.shared.variable; +import com.bamdoliro.maru.shared.constants.FixedNumber; import lombok.experimental.UtilityClass; @UtilityClass public class AdmissionCapacity { - public static int regular = 36; - public static int meisterTalent = 25; - public static int socialIntegration = 3; + public static int regular = FixedNumber.REGULAR; + public static int meisterTalent = FixedNumber.MEISTER_TALENT; + public static int socialIntegration = FixedNumber.SOCIAL_INTEGRATION; } From cffae791387069435084c37b2a12b089afc0bb38 Mon Sep 17 00:00:00 2001 From: cabbage16 Date: Thu, 11 Jul 2024 15:37:24 +0900 Subject: [PATCH 07/25] =?UTF-8?q?test(#98):=20FormControllerTest=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1=20-=20=EC=9E=90=EB=8F=99=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=202=EC=B0=A8=20=ED=95=A9=EA=B2=A9=20=EC=97=AC=EB=B6=80?= =?UTF-8?q?=EB=A5=BC=20=EA=B2=B0=EC=A0=95=ED=95=98=EB=8A=94=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=EB=A5=BC=20=EC=9E=91=EC=84=B1=ED=96=88?= =?UTF-8?q?=EC=96=B4=EC=9A=94.=20-=202=EC=B0=A8=20=ED=95=A9=EA=B2=A9=20?= =?UTF-8?q?=EC=97=AC=EB=B6=80=EB=A5=BC=20=EA=B2=B0=EC=A0=95=ED=95=A0=20?= =?UTF-8?q?=EB=95=8C=20=EC=B5=9C=EC=A2=85=20=EC=A0=90=EC=88=98=EA=B0=80=20?= =?UTF-8?q?=EC=97=86=EB=8A=94=20=EC=9B=90=EC=84=9C=EA=B0=80=20=EC=A1=B4?= =?UTF-8?q?=EC=9E=AC=ED=95=98=EB=A9=B4=20=EC=97=90=EB=9F=AC=EA=B0=80=20?= =?UTF-8?q?=EB=B0=9C=EC=83=9D=ED=95=98=EB=8A=94=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=EB=A5=BC=20=EC=9E=91=EC=84=B1=ED=96=88=EC=96=B4?= =?UTF-8?q?=EC=9A=94.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/form/domain/type/FormType.java | 2 +- .../exception/MissingTotalScoreException.java | 2 +- .../exception/error/FormErrorProperty.java | 2 +- .../presentation/form/FormControllerTest.java | 46 +++++++++++++++++-- .../maru/shared/util/ControllerTest.java | 30 ++---------- 5 files changed, 48 insertions(+), 34 deletions(-) diff --git a/src/main/java/com/bamdoliro/maru/domain/form/domain/type/FormType.java b/src/main/java/com/bamdoliro/maru/domain/form/domain/type/FormType.java index fa827815..5efb3845 100644 --- a/src/main/java/com/bamdoliro/maru/domain/form/domain/type/FormType.java +++ b/src/main/java/com/bamdoliro/maru/domain/form/domain/type/FormType.java @@ -19,7 +19,7 @@ public enum FormType implements EnumProperty { NATIONAL_VETERANS("국가보훈자녀", Category.SPECIAL, Category.SOCIAL_INTEGRATION, Category.EQUAL_OPPORTUNITY), ONE_PARENT("한부모가정", Category.SPECIAL, Category.SOCIAL_INTEGRATION, Category.EQUAL_OPPORTUNITY), - FROM_NORTH_KOREA("북한이탈주민", Category.SPECIAL, Category.SOCIAL_INTEGRATION, Category.SOCIETY_DIVERSITY), + FROM_NORTH_KOREA("북한이탈청소년", Category.SPECIAL, Category.SOCIAL_INTEGRATION, Category.SOCIETY_DIVERSITY), MULTICULTURAL("다문화가정", Category.SPECIAL, Category.SOCIAL_INTEGRATION, Category.SOCIETY_DIVERSITY), TEEN_HOUSEHOLDER("소년소녀가장", Category.SPECIAL, Category.SOCIAL_INTEGRATION, Category.SOCIETY_DIVERSITY), MULTI_CHILDREN("다자녀가정자녀", Category.SPECIAL, Category.SOCIAL_INTEGRATION, Category.SOCIETY_DIVERSITY), diff --git a/src/main/java/com/bamdoliro/maru/domain/form/exception/MissingTotalScoreException.java b/src/main/java/com/bamdoliro/maru/domain/form/exception/MissingTotalScoreException.java index 260beb7e..699d4509 100644 --- a/src/main/java/com/bamdoliro/maru/domain/form/exception/MissingTotalScoreException.java +++ b/src/main/java/com/bamdoliro/maru/domain/form/exception/MissingTotalScoreException.java @@ -5,6 +5,6 @@ public class MissingTotalScoreException extends MaruException { public MissingTotalScoreException() { - super(FormErrorProperty.TOTAL_SCORE_MISSING); + super(FormErrorProperty.MISSING_TOTAL_SCORE); } } diff --git a/src/main/java/com/bamdoliro/maru/domain/form/exception/error/FormErrorProperty.java b/src/main/java/com/bamdoliro/maru/domain/form/exception/error/FormErrorProperty.java index 308798d8..30e2fe09 100644 --- a/src/main/java/com/bamdoliro/maru/domain/form/exception/error/FormErrorProperty.java +++ b/src/main/java/com/bamdoliro/maru/domain/form/exception/error/FormErrorProperty.java @@ -15,7 +15,7 @@ public enum FormErrorProperty implements ErrorProperty { CANNOT_UPDATE_NOT_REJECTED_FORM(HttpStatus.CONFLICT, "반려된 원서만 수정할 수 있습니다."), INVALID_FORM_STATUS(HttpStatus.CONFLICT, "원서 상태가 유효하지 않습니다."), INVALID_FILE(HttpStatus.BAD_REQUEST, "잘못된 파일입니다."), - TOTAL_SCORE_MISSING(HttpStatus.PRECONDITION_FAILED, "최종 점수가 입력되지 않은 원서가 존재합니다.") + MISSING_TOTAL_SCORE(HttpStatus.PRECONDITION_FAILED, "최종 점수가 입력되지 않은 원서가 존재합니다.") ; private final HttpStatus status; diff --git a/src/test/java/com/bamdoliro/maru/presentation/form/FormControllerTest.java b/src/test/java/com/bamdoliro/maru/presentation/form/FormControllerTest.java index e788d4ba..f1b92974 100644 --- a/src/test/java/com/bamdoliro/maru/presentation/form/FormControllerTest.java +++ b/src/test/java/com/bamdoliro/maru/presentation/form/FormControllerTest.java @@ -4,11 +4,7 @@ import com.bamdoliro.maru.domain.form.domain.Form; import com.bamdoliro.maru.domain.form.domain.type.FormStatus; import com.bamdoliro.maru.domain.form.domain.type.FormType; -import com.bamdoliro.maru.domain.form.exception.CannotUpdateNotRejectedFormException; -import com.bamdoliro.maru.domain.form.exception.FormAlreadySubmittedException; -import com.bamdoliro.maru.domain.form.exception.FormNotFoundException; -import com.bamdoliro.maru.domain.form.exception.InvalidFileException; -import com.bamdoliro.maru.domain.form.exception.InvalidFormStatusException; +import com.bamdoliro.maru.domain.form.exception.*; import com.bamdoliro.maru.domain.user.domain.User; import com.bamdoliro.maru.infrastructure.pdf.exception.FailedToExportPdfException; import com.bamdoliro.maru.infrastructure.s3.dto.response.UploadResponse; @@ -1862,4 +1858,44 @@ class FormControllerTest extends RestDocsTestSupport { verify(queryFormUrlUseCase, times(1)).execute(idList); } + + @Test + void 자동으로_2차_합격_여부를_결정한다() throws Exception { + User user = UserFixture.createAdminUser(); + + given(authenticationArgumentResolver.supportsParameter(any(MethodParameter.class))).willReturn(true); + given(authenticationArgumentResolver.resolveArgument(any(), any(), any(), any())).willReturn(user); + willDoNothing().given(selectSecondPassUseCase).execute(); + + mockMvc.perform(patch("/form/second-round/select") + .header(HttpHeaders.AUTHORIZATION, AuthFixture.createAuthHeader())) + + .andExpect(status().isNoContent()) + + .andDo(restDocs.document( + requestHeaders( + headerWithName(HttpHeaders.AUTHORIZATION).description("Bearer token") + ) + )); + + verify(selectSecondPassUseCase, times(1)).execute(); + } + + @Test + void 자동으로_2차_합격_여부를_결정할_때_최종_점수가_없는_원서가_존재하면_에러가_발생한다() throws Exception { + User user = UserFixture.createAdminUser(); + + given(authenticationArgumentResolver.supportsParameter(any(MethodParameter.class))).willReturn(true); + given(authenticationArgumentResolver.resolveArgument(any(), any(), any(), any())).willReturn(user); + willThrow(new MissingTotalScoreException()).given(selectSecondPassUseCase).execute(); + + mockMvc.perform(patch("/form/second-round/select") + .header(HttpHeaders.AUTHORIZATION, AuthFixture.createAuthHeader())) + + .andExpect(status().isPreconditionFailed()) + + .andDo(restDocs.document()); + + verify(selectSecondPassUseCase, times(1)).execute(); + } } \ No newline at end of file diff --git a/src/test/java/com/bamdoliro/maru/shared/util/ControllerTest.java b/src/test/java/com/bamdoliro/maru/shared/util/ControllerTest.java index 19f1359c..970f5b8d 100644 --- a/src/test/java/com/bamdoliro/maru/shared/util/ControllerTest.java +++ b/src/test/java/com/bamdoliro/maru/shared/util/ControllerTest.java @@ -12,32 +12,7 @@ import com.bamdoliro.maru.application.fair.ExportAttendeeListUseCase; import com.bamdoliro.maru.application.fair.QueryFairDetailUseCase; import com.bamdoliro.maru.application.fair.QueryFairListUseCase; -import com.bamdoliro.maru.application.form.ApproveFormUseCase; -import com.bamdoliro.maru.application.form.DownloadSecondRoundScoreFormatUseCase; -import com.bamdoliro.maru.application.form.DraftFormUseCase; -import com.bamdoliro.maru.application.form.ExportFinalPassedFormUseCase; -import com.bamdoliro.maru.application.form.ExportFirstRoundResultUseCase; -import com.bamdoliro.maru.application.form.ExportFormUseCase; -import com.bamdoliro.maru.application.form.ExportResultUseCase; -import com.bamdoliro.maru.application.form.ExportSecondRoundResultUseCase; -import com.bamdoliro.maru.application.form.GenerateAdmissionTicketUseCase; -import com.bamdoliro.maru.application.form.PassOrFailFormUseCase; -import com.bamdoliro.maru.application.form.QueryAllFormUseCase; -import com.bamdoliro.maru.application.form.QueryDraftFormUseCase; -import com.bamdoliro.maru.application.form.QueryFinalFormResultUseCase; -import com.bamdoliro.maru.application.form.QueryFirstFormResultUseCase; -import com.bamdoliro.maru.application.form.QueryFormStatusUseCase; -import com.bamdoliro.maru.application.form.QueryFormUrlUseCase; -import com.bamdoliro.maru.application.form.QueryFormUseCase; -import com.bamdoliro.maru.application.form.QuerySubmittedFormUseCase; -import com.bamdoliro.maru.application.form.ReceiveFormUseCase; -import com.bamdoliro.maru.application.form.RejectFormUseCase; -import com.bamdoliro.maru.application.form.SubmitFinalFormUseCase; -import com.bamdoliro.maru.application.form.SubmitFormUseCase; -import com.bamdoliro.maru.application.form.UpdateFormUseCase; -import com.bamdoliro.maru.application.form.UpdateSecondRoundScoreUseCase; -import com.bamdoliro.maru.application.form.UploadFormUseCase; -import com.bamdoliro.maru.application.form.UploadIdentificationPictureUseCase; +import com.bamdoliro.maru.application.form.*; import com.bamdoliro.maru.application.message.SendMessageUseCase; import com.bamdoliro.maru.application.notice.CreateNoticeUseCase; import com.bamdoliro.maru.application.notice.DeleteNoticeUseCase; @@ -247,6 +222,9 @@ public abstract class ControllerTest { @MockBean protected QueryFormUrlUseCase queryFormUrlUseCase; + @MockBean + protected SelectSecondPassUseCase selectSecondPassUseCase; + @MockBean protected SendMessageUseCase sendMessageUseCase; From 0b884923c2e97baff38039c9e139859362e15f3f Mon Sep 17 00:00:00 2001 From: cabbage16 Date: Thu, 11 Jul 2024 15:42:23 +0900 Subject: [PATCH 08/25] =?UTF-8?q?docs(#98):=202=EC=B0=A8=20=ED=95=A9?= =?UTF-8?q?=EA=B2=A9=20=EC=97=AC=EB=B6=80=20=EC=9E=90=EB=8F=99=20=EA=B2=B0?= =?UTF-8?q?=EC=A0=95=20API=20=EB=AC=B8=EC=84=9C=20=EC=9E=91=EC=84=B1=20-?= =?UTF-8?q?=202=EC=B0=A8=20=ED=95=A9=EA=B2=A9=20=EC=97=AC=EB=B6=80?= =?UTF-8?q?=EB=A5=BC=20=EC=9E=90=EB=8F=99=EC=9C=BC=EB=A1=9C=20=EA=B2=B0?= =?UTF-8?q?=EC=A0=95=ED=95=98=EB=8A=94=20API=20=EB=A5=BC=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=ED=96=88=EC=96=B4=EC=9A=94.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/docs/asciidoc/form.adoc | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/docs/asciidoc/form.adoc b/src/docs/asciidoc/form.adoc index 200af395..e7992b68 100644 --- a/src/docs/asciidoc/form.adoc +++ b/src/docs/asciidoc/form.adoc @@ -585,4 +585,24 @@ include::{snippets}/form-controller-test/선택한_원서의_원서url을_조회 ==== 응답 ===== 정상 응답 -include::{snippets}/form-controller-test/선택한_원서의_원서url을_조회한다/http-response.adoc[] \ No newline at end of file +include::{snippets}/form-controller-test/선택한_원서의_원서url을_조회한다/http-response.adoc[] + + + +=== 2차 합격 자동 처리 + +==== 요청 형식 + +===== Request Header +include::{snippets}/form-controller-test/자동으로_2차_합격_여부를_결정한다/request-headers.adoc[] + +==== 요청 +include::{snippets}/form-controller-test/자동으로_2차_합격_여부를_결정한다/http-request.adoc[] + +==== 응답 + +===== 정상 응답 +include::{snippets}/form-controller-test/자동으로_2차_합격_여부를_결정한다/http-response.adoc[] + +===== 최종 점수가 없는 원서가 있을 경우 +include::{snippets}/form-controller-test/자동으로_2차_합격_여부를_결정할_때_최종_점수가_없는_원서가_존재하면_에러가_발생한다/http-response.adoc[] \ No newline at end of file From b10b6e11af52963d4d57e946a2fb01d86bade6f0 Mon Sep 17 00:00:00 2001 From: cabbage16 Date: Tue, 9 Jul 2024 16:22:25 +0900 Subject: [PATCH 09/25] =?UTF-8?q?feat(#98):=20=EC=B5=9C=EC=A2=85=20?= =?UTF-8?q?=ED=95=A9=EA=B2=A9=20=EC=97=AC=EB=B6=80=20=EA=B2=B0=EC=A0=95=20?= =?UTF-8?q?API=20=EC=9E=91=EC=84=B1=20-=20=EC=96=B4=EB=93=9C=EB=AF=BC?= =?UTF-8?q?=EC=9D=B4=20=EC=B5=9C=EC=A2=85=20=EC=A0=90=EC=88=98=20=EC=88=9C?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=B5=9C=EC=A2=85=20=ED=95=A9=EA=B2=A9=20?= =?UTF-8?q?=EC=97=AC=EB=B6=80=EB=A5=BC=20=EA=B2=B0=EC=A0=95=ED=95=A0=20?= =?UTF-8?q?=EC=88=98=20=EC=9E=88=EC=8A=B5=EB=8B=88=EB=8B=A4.=20-=201?= =?UTF-8?q?=EC=B0=A8=20=ED=95=A9=EA=B2=A9=20=EC=9B=90=EC=84=9C=20=EC=A4=91?= =?UTF-8?q?=20=EC=B5=9C=EC=A2=85=20=EC=A0=90=EC=88=98=EA=B0=80=20=EC=97=86?= =?UTF-8?q?=EB=8A=94=20=EC=9B=90=EC=84=9C=EA=B0=80=20=EC=9E=88=EB=8B=A4?= =?UTF-8?q?=EB=A9=B4=20=EC=98=88=EC=99=B8=EA=B0=80=20=EB=B0=9C=EC=83=9D?= =?UTF-8?q?=ED=95=A9=EB=8B=88=EB=8B=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/SelectFirstPassUseCase.java | 5 + .../form/SelectSecondPassUseCase.java | 101 ++++++++++++++++++ .../exception/TotalScoreMissingException.java | 11 ++ .../exception/error/FormErrorProperty.java | 1 + .../form/FormRepositoryCustom.java | 2 + .../persistence/form/FormRepositoryImpl.java | 37 +++++++ .../presentation/form/FormController.java | 33 ++---- .../shared/variable/AdmissionCapacity.java | 11 ++ 8 files changed, 177 insertions(+), 24 deletions(-) create mode 100644 src/main/java/com/bamdoliro/maru/application/form/SelectSecondPassUseCase.java create mode 100644 src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java create mode 100644 src/main/java/com/bamdoliro/maru/shared/variable/AdmissionCapacity.java diff --git a/src/main/java/com/bamdoliro/maru/application/form/SelectFirstPassUseCase.java b/src/main/java/com/bamdoliro/maru/application/form/SelectFirstPassUseCase.java index 186bfedb..e004d033 100644 --- a/src/main/java/com/bamdoliro/maru/application/form/SelectFirstPassUseCase.java +++ b/src/main/java/com/bamdoliro/maru/application/form/SelectFirstPassUseCase.java @@ -6,6 +6,7 @@ import com.bamdoliro.maru.infrastructure.persistence.form.FormRepository; import com.bamdoliro.maru.shared.annotation.UseCase; import com.bamdoliro.maru.shared.constants.FixedNumber; +import com.bamdoliro.maru.shared.variable.AdmissionCapacity; import lombok.RequiredArgsConstructor; import org.springframework.transaction.annotation.Transactional; @@ -34,12 +35,16 @@ public void execute() { int gap = FixedNumber.MEISTER_TALENT - meisterTalentFormList.size(); regularCount += gap; meisterTalentCount -= gap; + AdmissionCapacity.regular += gap; + AdmissionCapacity.meisterTalent -= gap; } if (socialIntegrationFormList.size() < FixedNumber.SOCIAL_INTEGRATION) { int gap = FixedNumber.SOCIAL_INTEGRATION - socialIntegrationFormList.size(); regularCount += gap; socialIntegrationCount -= gap; + AdmissionCapacity.regular += gap; + AdmissionCapacity.socialIntegration -= gap; } regularCount = calculateMultiple(regularCount); diff --git a/src/main/java/com/bamdoliro/maru/application/form/SelectSecondPassUseCase.java b/src/main/java/com/bamdoliro/maru/application/form/SelectSecondPassUseCase.java new file mode 100644 index 00000000..27382ac9 --- /dev/null +++ b/src/main/java/com/bamdoliro/maru/application/form/SelectSecondPassUseCase.java @@ -0,0 +1,101 @@ +package com.bamdoliro.maru.application.form; + +import com.bamdoliro.maru.domain.form.domain.Form; +import com.bamdoliro.maru.domain.form.domain.type.FormStatus; +import com.bamdoliro.maru.domain.form.domain.type.FormType; +import com.bamdoliro.maru.domain.form.exception.TotalScoreMissingException; +import com.bamdoliro.maru.infrastructure.persistence.form.FormRepository; +import com.bamdoliro.maru.shared.annotation.UseCase; +import com.bamdoliro.maru.shared.constants.FixedNumber; +import com.bamdoliro.maru.shared.variable.AdmissionCapacity; +import jakarta.transaction.Transactional; +import lombok.RequiredArgsConstructor; + +import java.util.List; + +@RequiredArgsConstructor +@UseCase +public class SelectSecondPassUseCase { + + private final FormRepository formRepository; + + @Transactional + public void execute() { + validate(); + + int regularCount = AdmissionCapacity.regular; + int meisterTalentCount = AdmissionCapacity.meisterTalent; + int socialIntegrationCount = AdmissionCapacity.socialIntegration; + int nationalVeteransEducationCount = FixedNumber.NATIONAL_VETERANS_EDUCATION; + int specialAdmissionCount = FixedNumber.SPECIAL_ADMISSION; + int equalOpportunityCount = (int) Math.round(socialIntegrationCount * 0.5); + int societyDiversityCount = equalOpportunityCount; + + List specialFormList = formRepository.findFirstPassedSpecialForm(); + List meisterTalentFormList = classifyFormsByType(specialFormList, FormType::isMeister); + List socialIntegrationFormList = classifyFormsByType(specialFormList, FormType::isSocial); + + for (Form form : socialIntegrationFormList) { + if (form.getType().isEqualOpportunity() && equalOpportunityCount > 0) { + form.pass(); + equalOpportunityCount--; + } else if (form.getType().isSocietyDiversity() && societyDiversityCount > 0) { + form.pass(); + societyDiversityCount--; + } else { + form.fail(); + } + } + + for (Form form : meisterTalentFormList) { + if (meisterTalentCount > 0) { + form.pass(); + meisterTalentCount--; + } else { + form.fail(); + } + } + + formRepository.flush(); + List regularOrSupernumeraryFormList = formRepository.findFirstPassedRegularOrSupernumeraryForm(); + System.out.println(regularOrSupernumeraryFormList.size()); + + for (Form form : regularOrSupernumeraryFormList) { + if (form.getType().isRegular() && regularCount > 0) { + form.pass(); + regularCount--; + } else if ( + form.getType().isNationalVeteransEducation() && + regularCount > 0 && + nationalVeteransEducationCount > 0 + ) { + form.pass(); + nationalVeteransEducationCount--; + } else if ( + form.getType().isSpecialAdmission() && + regularCount > 0 && + specialAdmissionCount > 0 + ) { + form.pass(); + specialAdmissionCount--; + } else { + form.fail(); + } + } + } + + private void validate() { + List firstPassedFormList = formRepository.findByStatus(FormStatus.FIRST_PASSED); + for (Form form : firstPassedFormList) { + if (form.getScore().getTotalScore() == null) { + throw new TotalScoreMissingException(); + } + } + } + + private List classifyFormsByType(List formList, FormTypeFilter filter) { + return formList.stream() + .filter(form -> filter.execute(form.getType())) + .toList(); + } +} diff --git a/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java b/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java new file mode 100644 index 00000000..028d46ff --- /dev/null +++ b/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java @@ -0,0 +1,11 @@ +package com.bamdoliro.maru.domain.form.exception; + +import com.bamdoliro.maru.domain.form.exception.error.FormErrorProperty; +import com.bamdoliro.maru.shared.error.ErrorProperty; +import com.bamdoliro.maru.shared.error.MaruException; + +public class TotalScoreMissingException extends MaruException { + public TotalScoreMissingException() { + super(FormErrorProperty.TOTAL_SCORE_MISSING); + } +} diff --git a/src/main/java/com/bamdoliro/maru/domain/form/exception/error/FormErrorProperty.java b/src/main/java/com/bamdoliro/maru/domain/form/exception/error/FormErrorProperty.java index 99af1e5f..308798d8 100644 --- a/src/main/java/com/bamdoliro/maru/domain/form/exception/error/FormErrorProperty.java +++ b/src/main/java/com/bamdoliro/maru/domain/form/exception/error/FormErrorProperty.java @@ -15,6 +15,7 @@ public enum FormErrorProperty implements ErrorProperty { CANNOT_UPDATE_NOT_REJECTED_FORM(HttpStatus.CONFLICT, "반려된 원서만 수정할 수 있습니다."), INVALID_FORM_STATUS(HttpStatus.CONFLICT, "원서 상태가 유효하지 않습니다."), INVALID_FILE(HttpStatus.BAD_REQUEST, "잘못된 파일입니다."), + TOTAL_SCORE_MISSING(HttpStatus.PRECONDITION_FAILED, "최종 점수가 입력되지 않은 원서가 존재합니다.") ; private final HttpStatus status; diff --git a/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryCustom.java b/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryCustom.java index a6704019..ab913eb6 100644 --- a/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryCustom.java +++ b/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryCustom.java @@ -17,6 +17,8 @@ public interface FormRepositoryCustom { List findByCategory(FormType.Category category); List findReceivedSpecialForm(); List findReceivedRegularOrSupernumeraryForm(); + List findFirstPassedSpecialForm(); + List findFirstPassedRegularOrSupernumeraryForm(); List findFirstRoundForm(); List findMeisterTalentFirstRoundForm(); List findNotExistsMeisterTalentAndChangedToRegularFirstRoundForm(); diff --git a/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryImpl.java b/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryImpl.java index f64b67a2..1783f9b2 100644 --- a/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryImpl.java +++ b/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryImpl.java @@ -109,6 +109,43 @@ public List findReceivedRegularOrSupernumeraryForm() { .fetch(); } + @Override + public List findFirstPassedSpecialForm() { + return queryFactory + .selectFrom(form) + .where( + form.status.eq(FormStatus.FIRST_PASSED) + .and( + form.type.eq(FormType.REGULAR).not() + .and(form.type.eq(FormType.NATIONAL_VETERANS_EDUCATION).not()) + .and(form.type.eq(FormType.SPECIAL_ADMISSION).not()) + ) + ) + .orderBy( + form.score.totalScore.desc() + ) + .fetch(); + } + + @Override + public List findFirstPassedRegularOrSupernumeraryForm() { + return queryFactory + .selectFrom(form) + .where( + form.status.eq(FormStatus.FIRST_PASSED) + .and( + form.type.eq(FormType.REGULAR) + .or(form.type.eq(FormType.NATIONAL_VETERANS_EDUCATION)) + .or(form.type.eq(FormType.SPECIAL_ADMISSION)) + .or(form.changedToRegular.isTrue()) + ) + ) + .orderBy( + form.score.totalScore.desc() + ) + .fetch(); + } + @Override public List findFirstRoundForm() { return queryFactory diff --git a/src/main/java/com/bamdoliro/maru/presentation/form/FormController.java b/src/main/java/com/bamdoliro/maru/presentation/form/FormController.java index 85d1dcc0..ad6560e2 100644 --- a/src/main/java/com/bamdoliro/maru/presentation/form/FormController.java +++ b/src/main/java/com/bamdoliro/maru/presentation/form/FormController.java @@ -1,29 +1,6 @@ package com.bamdoliro.maru.presentation.form; -import com.bamdoliro.maru.application.form.ApproveFormUseCase; -import com.bamdoliro.maru.application.form.DownloadSecondRoundScoreFormatUseCase; -import com.bamdoliro.maru.application.form.ExportFinalPassedFormUseCase; -import com.bamdoliro.maru.application.form.ExportFirstRoundResultUseCase; -import com.bamdoliro.maru.application.form.ExportFormUseCase; -import com.bamdoliro.maru.application.form.ExportResultUseCase; -import com.bamdoliro.maru.application.form.ExportSecondRoundResultUseCase; -import com.bamdoliro.maru.application.form.GenerateAdmissionTicketUseCase; -import com.bamdoliro.maru.application.form.PassOrFailFormUseCase; -import com.bamdoliro.maru.application.form.QueryAllFormUseCase; -import com.bamdoliro.maru.application.form.QueryFinalFormResultUseCase; -import com.bamdoliro.maru.application.form.QueryFirstFormResultUseCase; -import com.bamdoliro.maru.application.form.QueryFormStatusUseCase; -import com.bamdoliro.maru.application.form.QueryFormUrlUseCase; -import com.bamdoliro.maru.application.form.QueryFormUseCase; -import com.bamdoliro.maru.application.form.QuerySubmittedFormUseCase; -import com.bamdoliro.maru.application.form.ReceiveFormUseCase; -import com.bamdoliro.maru.application.form.RejectFormUseCase; -import com.bamdoliro.maru.application.form.SubmitFinalFormUseCase; -import com.bamdoliro.maru.application.form.SubmitFormUseCase; -import com.bamdoliro.maru.application.form.UpdateFormUseCase; -import com.bamdoliro.maru.application.form.UpdateSecondRoundScoreUseCase; -import com.bamdoliro.maru.application.form.UploadFormUseCase; -import com.bamdoliro.maru.application.form.UploadIdentificationPictureUseCase; +import com.bamdoliro.maru.application.form.*; import com.bamdoliro.maru.domain.form.domain.type.FormStatus; import com.bamdoliro.maru.domain.form.domain.type.FormType; import com.bamdoliro.maru.domain.user.domain.User; @@ -92,6 +69,7 @@ public class FormController { private final ExportResultUseCase exportResultUseCase; private final PassOrFailFormUseCase passOrFailFormUseCase; private final QueryFormUrlUseCase queryFormUrlUseCase; + private final SelectSecondPassUseCase selectSecondPassUseCase; @ResponseStatus(HttpStatus.CREATED) @PostMapping @@ -320,4 +298,11 @@ public ListCommonResponse getFormUrl( queryFormUrlUseCase.execute(formIdList) ); } + + @PatchMapping("/second-pass") + public void selectSecondPass( + @AuthenticationPrincipal(authority = Authority.ADMIN) User user + ) { + selectSecondPassUseCase.execute(); + } } \ No newline at end of file diff --git a/src/main/java/com/bamdoliro/maru/shared/variable/AdmissionCapacity.java b/src/main/java/com/bamdoliro/maru/shared/variable/AdmissionCapacity.java new file mode 100644 index 00000000..4e87bb11 --- /dev/null +++ b/src/main/java/com/bamdoliro/maru/shared/variable/AdmissionCapacity.java @@ -0,0 +1,11 @@ +package com.bamdoliro.maru.shared.variable; + +import lombok.experimental.UtilityClass; + +@UtilityClass +public class AdmissionCapacity { + + public static int regular = 36; + public static int meisterTalent = 25; + public static int socialIntegration = 3; +} From 374fe32e57d0517dfad6ffd560067e41a8d44999 Mon Sep 17 00:00:00 2001 From: cabbage16 Date: Tue, 9 Jul 2024 16:23:03 +0900 Subject: [PATCH 10/25] =?UTF-8?q?refactor(#98):=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20import=20=EB=AC=B8=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../maru/domain/form/exception/TotalScoreMissingException.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java b/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java index 028d46ff..22557233 100644 --- a/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java +++ b/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java @@ -1,7 +1,6 @@ package com.bamdoliro.maru.domain.form.exception; import com.bamdoliro.maru.domain.form.exception.error.FormErrorProperty; -import com.bamdoliro.maru.shared.error.ErrorProperty; import com.bamdoliro.maru.shared.error.MaruException; public class TotalScoreMissingException extends MaruException { From 17b47c03f614028ce28bebc39fdeb46272a7499c Mon Sep 17 00:00:00 2001 From: cabbage16 Date: Wed, 10 Jul 2024 08:22:13 +0900 Subject: [PATCH 11/25] =?UTF-8?q?refactor(#98):=20=EC=98=88=EC=99=B8=20?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=20=EC=88=98=EC=A0=95=20-=20=EC=9E=98?= =?UTF-8?q?=EB=AA=BB=EB=90=9C=20=EC=9D=B4=EB=A6=84=EC=9D=84=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=ED=95=98=EA=B3=A0=20=EC=A2=80=20=EB=8D=94=20=EC=9D=98?= =?UTF-8?q?=EB=AF=B8=EC=97=90=20=EB=A7=9E=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=ED=96=88=EC=8A=B5=EB=8B=88=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/form/GenerateAdmissionTicketUseCase.java | 4 ++-- ...StatusException.java => InvalidFormStatusException.java} | 4 ++-- ...issingException.java => MissingTotalScoreException.java} | 4 ++-- .../form/GenerateAdmissionTicketUseCaseTest.java | 6 ++---- .../maru/presentation/form/FormControllerTest.java | 4 ++-- 5 files changed, 10 insertions(+), 12 deletions(-) rename src/main/java/com/bamdoliro/maru/domain/form/exception/{InvalidFromStatusException.java => InvalidFormStatusException.java} (69%) rename src/main/java/com/bamdoliro/maru/domain/form/exception/{TotalScoreMissingException.java => MissingTotalScoreException.java} (69%) diff --git a/src/main/java/com/bamdoliro/maru/application/form/GenerateAdmissionTicketUseCase.java b/src/main/java/com/bamdoliro/maru/application/form/GenerateAdmissionTicketUseCase.java index 5e9c071f..9022082d 100644 --- a/src/main/java/com/bamdoliro/maru/application/form/GenerateAdmissionTicketUseCase.java +++ b/src/main/java/com/bamdoliro/maru/application/form/GenerateAdmissionTicketUseCase.java @@ -1,7 +1,7 @@ package com.bamdoliro.maru.application.form; import com.bamdoliro.maru.domain.form.domain.Form; -import com.bamdoliro.maru.domain.form.exception.InvalidFromStatusException; +import com.bamdoliro.maru.domain.form.exception.InvalidFormStatusException; import com.bamdoliro.maru.domain.form.service.FormFacade; import com.bamdoliro.maru.domain.user.domain.User; import com.bamdoliro.maru.infrastructure.pdf.GeneratePdfService; @@ -48,7 +48,7 @@ public ByteArrayResource execute(User user) { private void validateFormStatus(Form form) { if (!form.isFirstPassedNow()) { - throw new InvalidFromStatusException(); + throw new InvalidFormStatusException(); } } } diff --git a/src/main/java/com/bamdoliro/maru/domain/form/exception/InvalidFromStatusException.java b/src/main/java/com/bamdoliro/maru/domain/form/exception/InvalidFormStatusException.java similarity index 69% rename from src/main/java/com/bamdoliro/maru/domain/form/exception/InvalidFromStatusException.java rename to src/main/java/com/bamdoliro/maru/domain/form/exception/InvalidFormStatusException.java index 7ac0e431..8e4e990e 100644 --- a/src/main/java/com/bamdoliro/maru/domain/form/exception/InvalidFromStatusException.java +++ b/src/main/java/com/bamdoliro/maru/domain/form/exception/InvalidFormStatusException.java @@ -3,9 +3,9 @@ import com.bamdoliro.maru.domain.form.exception.error.FormErrorProperty; import com.bamdoliro.maru.shared.error.MaruException; -public class InvalidFromStatusException extends MaruException { +public class InvalidFormStatusException extends MaruException { - public InvalidFromStatusException() { + public InvalidFormStatusException() { super(FormErrorProperty.INVALID_FORM_STATUS); } } diff --git a/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java b/src/main/java/com/bamdoliro/maru/domain/form/exception/MissingTotalScoreException.java similarity index 69% rename from src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java rename to src/main/java/com/bamdoliro/maru/domain/form/exception/MissingTotalScoreException.java index 22557233..260beb7e 100644 --- a/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java +++ b/src/main/java/com/bamdoliro/maru/domain/form/exception/MissingTotalScoreException.java @@ -3,8 +3,8 @@ import com.bamdoliro.maru.domain.form.exception.error.FormErrorProperty; import com.bamdoliro.maru.shared.error.MaruException; -public class TotalScoreMissingException extends MaruException { - public TotalScoreMissingException() { +public class MissingTotalScoreException extends MaruException { + public MissingTotalScoreException() { super(FormErrorProperty.TOTAL_SCORE_MISSING); } } diff --git a/src/test/java/com/bamdoliro/maru/application/form/GenerateAdmissionTicketUseCaseTest.java b/src/test/java/com/bamdoliro/maru/application/form/GenerateAdmissionTicketUseCaseTest.java index a23ad2e6..8b0cb7b6 100644 --- a/src/test/java/com/bamdoliro/maru/application/form/GenerateAdmissionTicketUseCaseTest.java +++ b/src/test/java/com/bamdoliro/maru/application/form/GenerateAdmissionTicketUseCaseTest.java @@ -3,12 +3,11 @@ import com.bamdoliro.maru.domain.form.domain.Form; import com.bamdoliro.maru.domain.form.domain.type.FormType; import com.bamdoliro.maru.domain.form.exception.FormNotFoundException; -import com.bamdoliro.maru.domain.form.exception.InvalidFromStatusException; +import com.bamdoliro.maru.domain.form.exception.InvalidFormStatusException; import com.bamdoliro.maru.domain.form.service.FormFacade; import com.bamdoliro.maru.domain.user.domain.User; import com.bamdoliro.maru.infrastructure.pdf.GeneratePdfService; import com.bamdoliro.maru.infrastructure.thymeleaf.ProcessTemplateService; -import com.bamdoliro.maru.infrastructure.thymeleaf.Templates; import com.bamdoliro.maru.shared.fixture.FormFixture; import com.bamdoliro.maru.shared.fixture.UserFixture; import org.junit.jupiter.api.Test; @@ -22,7 +21,6 @@ import static org.junit.jupiter.api.Assertions.*; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.willThrow; import static org.mockito.Mockito.never; @@ -71,7 +69,7 @@ class GenerateAdmissionTicketUseCaseTest { given(formFacade.getForm(user)).willReturn(form); // when and then - assertThrows(InvalidFromStatusException.class, () -> generateAdmissionTicketUseCase.execute(user)); + assertThrows(InvalidFormStatusException.class, () -> generateAdmissionTicketUseCase.execute(user)); verify(formFacade, times(1)).getForm(user); verify(processTemplateService, never()).execute(any(String.class), any(Map.class)); diff --git a/src/test/java/com/bamdoliro/maru/presentation/form/FormControllerTest.java b/src/test/java/com/bamdoliro/maru/presentation/form/FormControllerTest.java index 91f59949..7f90f05c 100644 --- a/src/test/java/com/bamdoliro/maru/presentation/form/FormControllerTest.java +++ b/src/test/java/com/bamdoliro/maru/presentation/form/FormControllerTest.java @@ -8,7 +8,7 @@ import com.bamdoliro.maru.domain.form.exception.FormAlreadySubmittedException; import com.bamdoliro.maru.domain.form.exception.FormNotFoundException; import com.bamdoliro.maru.domain.form.exception.InvalidFileException; -import com.bamdoliro.maru.domain.form.exception.InvalidFromStatusException; +import com.bamdoliro.maru.domain.form.exception.InvalidFormStatusException; import com.bamdoliro.maru.domain.user.domain.User; import com.bamdoliro.maru.infrastructure.pdf.exception.FailedToExportPdfException; import com.bamdoliro.maru.infrastructure.s3.dto.response.UploadResponse; @@ -1510,7 +1510,7 @@ class FormControllerTest extends RestDocsTestSupport { given(authenticationArgumentResolver.supportsParameter(any(MethodParameter.class))).willReturn(true); given(authenticationArgumentResolver.resolveArgument(any(), any(), any(), any())).willReturn(user); - willThrow(new InvalidFromStatusException()).given(generateAdmissionTicketUseCase).execute(user); + willThrow(new InvalidFormStatusException()).given(generateAdmissionTicketUseCase).execute(user); mockMvc.perform(get("/form/admission-ticket") .header(HttpHeaders.AUTHORIZATION, AuthFixture.createAuthHeader()) From 7265cbe3aecf638d89072d4e4e553cb1f6ebbbfb Mon Sep 17 00:00:00 2001 From: cabbage16 Date: Wed, 10 Jul 2024 08:24:46 +0900 Subject: [PATCH 12/25] =?UTF-8?q?perf(#98):=20=EC=A0=95=EC=9B=90=20?= =?UTF-8?q?=EC=99=B8=20=EC=A0=84=ED=98=95=EC=9D=B4=20=EB=8B=A4=EB=A5=B8=20?= =?UTF-8?q?=EC=A0=84=ED=98=95=EA=B3=BC=20=EB=8F=85=EB=A6=BD=ED=95=98?= =?UTF-8?q?=EC=97=AC=20=EA=B2=BD=EC=9F=81=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20-=20=EC=A0=95=EC=9B=90=20=EC=99=B8=20?= =?UTF-8?q?=EC=A0=84=ED=98=95=EC=9D=80=20=EB=8B=A4=EB=A5=B8=20=EC=A0=84?= =?UTF-8?q?=ED=98=95=EB=93=A4=EA=B3=BC=20=ED=95=A8=EA=BB=98=20=EA=B2=BD?= =?UTF-8?q?=EC=9F=81=ED=95=98=EC=A7=80=20=EC=95=8A=EA=B3=A0=20=EC=99=84?= =?UTF-8?q?=EC=A0=84=ED=9E=88=20=EB=8F=85=EB=A6=BD=EB=90=98=EC=96=B4=20?= =?UTF-8?q?=EA=B2=BD=EC=9F=81=ED=95=B4=EC=95=BC=ED=95=98=EC=97=AC=EC=84=9C?= =?UTF-8?q?=20=EC=88=98=EC=A0=95=ED=96=88=EC=8A=B5=EB=8B=88=EB=8B=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/SelectFirstPassUseCase.java | 17 ++++++--- .../form/SelectSecondPassUseCase.java | 38 +++++++++---------- .../form/FormRepositoryCustom.java | 6 ++- .../persistence/form/FormRepositoryImpl.java | 35 ++++++++++++++--- .../presentation/form/FormController.java | 3 +- .../shared/variable/AdmissionCapacity.java | 7 ++-- 6 files changed, 69 insertions(+), 37 deletions(-) diff --git a/src/main/java/com/bamdoliro/maru/application/form/SelectFirstPassUseCase.java b/src/main/java/com/bamdoliro/maru/application/form/SelectFirstPassUseCase.java index e004d033..c7fe7508 100644 --- a/src/main/java/com/bamdoliro/maru/application/form/SelectFirstPassUseCase.java +++ b/src/main/java/com/bamdoliro/maru/application/form/SelectFirstPassUseCase.java @@ -78,22 +78,29 @@ public void execute() { } formRepository.flush(); - List regularOrSupernumeraryFormList = formRepository.findReceivedRegularOrSupernumeraryForm(); + List regularOrSupernumeraryFormList = formRepository.findReceivedRegularForm(); for (Form form : regularOrSupernumeraryFormList) { - if (form.getType().isRegular() && regularCount > 0) { + if (regularCount > 0) { form.firstPass(); regularCount--; - } else if ( + } else { + form.firstFail(); + } + } + + formRepository.flush(); + List supernumeraryFormList = formRepository.findReceivedSupernumeraryForm(); + + for (Form form : supernumeraryFormList) { + if ( form.getType().isNationalVeteransEducation() && - regularCount > 0 && nationalVeteransEducationCount > 0 ) { form.firstPass(); nationalVeteransEducationCount--; } else if ( form.getType().isSpecialAdmission() && - regularCount > 0 && specialAdmissionCount > 0 ) { form.firstPass(); diff --git a/src/main/java/com/bamdoliro/maru/application/form/SelectSecondPassUseCase.java b/src/main/java/com/bamdoliro/maru/application/form/SelectSecondPassUseCase.java index 27382ac9..1eef48f4 100644 --- a/src/main/java/com/bamdoliro/maru/application/form/SelectSecondPassUseCase.java +++ b/src/main/java/com/bamdoliro/maru/application/form/SelectSecondPassUseCase.java @@ -3,7 +3,7 @@ import com.bamdoliro.maru.domain.form.domain.Form; import com.bamdoliro.maru.domain.form.domain.type.FormStatus; import com.bamdoliro.maru.domain.form.domain.type.FormType; -import com.bamdoliro.maru.domain.form.exception.TotalScoreMissingException; +import com.bamdoliro.maru.domain.form.exception.MissingTotalScoreException; import com.bamdoliro.maru.infrastructure.persistence.form.FormRepository; import com.bamdoliro.maru.shared.annotation.UseCase; import com.bamdoliro.maru.shared.constants.FixedNumber; @@ -57,25 +57,25 @@ public void execute() { } formRepository.flush(); - List regularOrSupernumeraryFormList = formRepository.findFirstPassedRegularOrSupernumeraryForm(); - System.out.println(regularOrSupernumeraryFormList.size()); + List regularFormList = formRepository.findFirstPassedRegularForm(); - for (Form form : regularOrSupernumeraryFormList) { - if (form.getType().isRegular() && regularCount > 0) { + for (Form form : regularFormList) { + if (regularCount > 0) { form.pass(); regularCount--; - } else if ( - form.getType().isNationalVeteransEducation() && - regularCount > 0 && - nationalVeteransEducationCount > 0 - ) { + } else { + form.fail(); + } + } + + formRepository.flush(); + List supernumeraryFormList = formRepository.findFirstPassedSupernumeraryForm(); + + for (Form form : supernumeraryFormList) { + if (form.getType().isNationalVeteransEducation() && nationalVeteransEducationCount > 0) { form.pass(); nationalVeteransEducationCount--; - } else if ( - form.getType().isSpecialAdmission() && - regularCount > 0 && - specialAdmissionCount > 0 - ) { + } else if (form.getType().isSpecialAdmission() && specialAdmissionCount > 0) { form.pass(); specialAdmissionCount--; } else { @@ -86,11 +86,9 @@ public void execute() { private void validate() { List firstPassedFormList = formRepository.findByStatus(FormStatus.FIRST_PASSED); - for (Form form : firstPassedFormList) { - if (form.getScore().getTotalScore() == null) { - throw new TotalScoreMissingException(); - } - } + firstPassedFormList.stream() + .filter(form -> form.getScore().getTotalScore() == null) + .forEach(form -> {throw new MissingTotalScoreException();}); } private List classifyFormsByType(List formList, FormTypeFilter filter) { diff --git a/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryCustom.java b/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryCustom.java index ab913eb6..672bfa7c 100644 --- a/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryCustom.java +++ b/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryCustom.java @@ -16,9 +16,11 @@ public interface FormRepositoryCustom { List findByType(FormType type); List findByCategory(FormType.Category category); List findReceivedSpecialForm(); - List findReceivedRegularOrSupernumeraryForm(); + List findReceivedRegularForm(); + List findReceivedSupernumeraryForm(); List findFirstPassedSpecialForm(); - List findFirstPassedRegularOrSupernumeraryForm(); + List findFirstPassedRegularForm(); + List findFirstPassedSupernumeraryForm(); List findFirstRoundForm(); List findMeisterTalentFirstRoundForm(); List findNotExistsMeisterTalentAndChangedToRegularFirstRoundForm(); diff --git a/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryImpl.java b/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryImpl.java index 1783f9b2..eaaec14d 100644 --- a/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryImpl.java +++ b/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryImpl.java @@ -91,15 +91,13 @@ public List findReceivedSpecialForm() { } @Override - public List findReceivedRegularOrSupernumeraryForm() { + public List findReceivedRegularForm() { return queryFactory .selectFrom(form) .where( form.status.eq(FormStatus.RECEIVED) .and( form.type.eq(FormType.REGULAR) - .or(form.type.eq(FormType.NATIONAL_VETERANS_EDUCATION)) - .or(form.type.eq(FormType.SPECIAL_ADMISSION)) .or(form.changedToRegular.isTrue()) ) ) @@ -109,6 +107,23 @@ public List findReceivedRegularOrSupernumeraryForm() { .fetch(); } + @Override + public List findReceivedSupernumeraryForm() { + return queryFactory + .selectFrom(form) + .where( + form.status.eq(FormStatus.RECEIVED) + .and( + form.type.eq(FormType.SPECIAL_ADMISSION) + .or(form.type.eq(FormType.NATIONAL_VETERANS_EDUCATION)) + ) + ) + .orderBy( + form.score.firstRoundScore.desc() + ) + .fetch(); + } + @Override public List findFirstPassedSpecialForm() { return queryFactory @@ -128,15 +143,13 @@ public List findFirstPassedSpecialForm() { } @Override - public List findFirstPassedRegularOrSupernumeraryForm() { + public List findFirstPassedRegularForm() { return queryFactory .selectFrom(form) .where( form.status.eq(FormStatus.FIRST_PASSED) .and( form.type.eq(FormType.REGULAR) - .or(form.type.eq(FormType.NATIONAL_VETERANS_EDUCATION)) - .or(form.type.eq(FormType.SPECIAL_ADMISSION)) .or(form.changedToRegular.isTrue()) ) ) @@ -146,6 +159,16 @@ public List findFirstPassedRegularOrSupernumeraryForm() { .fetch(); } + @Override + public List findFirstPassedSupernumeraryForm() { + return List.of(); + } + +// @Override +// public List findFirstPassedRegularOrSupernumeraryForm() { +// +// } + @Override public List findFirstRoundForm() { return queryFactory diff --git a/src/main/java/com/bamdoliro/maru/presentation/form/FormController.java b/src/main/java/com/bamdoliro/maru/presentation/form/FormController.java index ad6560e2..5983885c 100644 --- a/src/main/java/com/bamdoliro/maru/presentation/form/FormController.java +++ b/src/main/java/com/bamdoliro/maru/presentation/form/FormController.java @@ -299,7 +299,8 @@ public ListCommonResponse getFormUrl( ); } - @PatchMapping("/second-pass") + @ResponseStatus(HttpStatus.NO_CONTENT) + @PatchMapping("/second-round/select") public void selectSecondPass( @AuthenticationPrincipal(authority = Authority.ADMIN) User user ) { diff --git a/src/main/java/com/bamdoliro/maru/shared/variable/AdmissionCapacity.java b/src/main/java/com/bamdoliro/maru/shared/variable/AdmissionCapacity.java index 4e87bb11..15266c5d 100644 --- a/src/main/java/com/bamdoliro/maru/shared/variable/AdmissionCapacity.java +++ b/src/main/java/com/bamdoliro/maru/shared/variable/AdmissionCapacity.java @@ -1,11 +1,12 @@ package com.bamdoliro.maru.shared.variable; +import com.bamdoliro.maru.shared.constants.FixedNumber; import lombok.experimental.UtilityClass; @UtilityClass public class AdmissionCapacity { - public static int regular = 36; - public static int meisterTalent = 25; - public static int socialIntegration = 3; + public static int regular = FixedNumber.REGULAR; + public static int meisterTalent = FixedNumber.MEISTER_TALENT; + public static int socialIntegration = FixedNumber.SOCIAL_INTEGRATION; } From 2b3fba8276642d34e1d74857bc60508caeb31a96 Mon Sep 17 00:00:00 2001 From: cabbage16 Date: Thu, 11 Jul 2024 15:37:24 +0900 Subject: [PATCH 13/25] =?UTF-8?q?test(#98):=20FormControllerTest=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1=20-=20=EC=9E=90=EB=8F=99=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=202=EC=B0=A8=20=ED=95=A9=EA=B2=A9=20=EC=97=AC=EB=B6=80?= =?UTF-8?q?=EB=A5=BC=20=EA=B2=B0=EC=A0=95=ED=95=98=EB=8A=94=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=EB=A5=BC=20=EC=9E=91=EC=84=B1=ED=96=88?= =?UTF-8?q?=EC=96=B4=EC=9A=94.=20-=202=EC=B0=A8=20=ED=95=A9=EA=B2=A9=20?= =?UTF-8?q?=EC=97=AC=EB=B6=80=EB=A5=BC=20=EA=B2=B0=EC=A0=95=ED=95=A0=20?= =?UTF-8?q?=EB=95=8C=20=EC=B5=9C=EC=A2=85=20=EC=A0=90=EC=88=98=EA=B0=80=20?= =?UTF-8?q?=EC=97=86=EB=8A=94=20=EC=9B=90=EC=84=9C=EA=B0=80=20=EC=A1=B4?= =?UTF-8?q?=EC=9E=AC=ED=95=98=EB=A9=B4=20=EC=97=90=EB=9F=AC=EA=B0=80=20?= =?UTF-8?q?=EB=B0=9C=EC=83=9D=ED=95=98=EB=8A=94=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=EB=A5=BC=20=EC=9E=91=EC=84=B1=ED=96=88=EC=96=B4?= =?UTF-8?q?=EC=9A=94.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/form/domain/type/FormType.java | 2 +- .../exception/MissingTotalScoreException.java | 2 +- .../exception/error/FormErrorProperty.java | 2 +- .../presentation/form/FormControllerTest.java | 46 +++++++++++++++++-- .../maru/shared/util/ControllerTest.java | 30 ++---------- 5 files changed, 48 insertions(+), 34 deletions(-) diff --git a/src/main/java/com/bamdoliro/maru/domain/form/domain/type/FormType.java b/src/main/java/com/bamdoliro/maru/domain/form/domain/type/FormType.java index fa827815..5efb3845 100644 --- a/src/main/java/com/bamdoliro/maru/domain/form/domain/type/FormType.java +++ b/src/main/java/com/bamdoliro/maru/domain/form/domain/type/FormType.java @@ -19,7 +19,7 @@ public enum FormType implements EnumProperty { NATIONAL_VETERANS("국가보훈자녀", Category.SPECIAL, Category.SOCIAL_INTEGRATION, Category.EQUAL_OPPORTUNITY), ONE_PARENT("한부모가정", Category.SPECIAL, Category.SOCIAL_INTEGRATION, Category.EQUAL_OPPORTUNITY), - FROM_NORTH_KOREA("북한이탈주민", Category.SPECIAL, Category.SOCIAL_INTEGRATION, Category.SOCIETY_DIVERSITY), + FROM_NORTH_KOREA("북한이탈청소년", Category.SPECIAL, Category.SOCIAL_INTEGRATION, Category.SOCIETY_DIVERSITY), MULTICULTURAL("다문화가정", Category.SPECIAL, Category.SOCIAL_INTEGRATION, Category.SOCIETY_DIVERSITY), TEEN_HOUSEHOLDER("소년소녀가장", Category.SPECIAL, Category.SOCIAL_INTEGRATION, Category.SOCIETY_DIVERSITY), MULTI_CHILDREN("다자녀가정자녀", Category.SPECIAL, Category.SOCIAL_INTEGRATION, Category.SOCIETY_DIVERSITY), diff --git a/src/main/java/com/bamdoliro/maru/domain/form/exception/MissingTotalScoreException.java b/src/main/java/com/bamdoliro/maru/domain/form/exception/MissingTotalScoreException.java index 260beb7e..699d4509 100644 --- a/src/main/java/com/bamdoliro/maru/domain/form/exception/MissingTotalScoreException.java +++ b/src/main/java/com/bamdoliro/maru/domain/form/exception/MissingTotalScoreException.java @@ -5,6 +5,6 @@ public class MissingTotalScoreException extends MaruException { public MissingTotalScoreException() { - super(FormErrorProperty.TOTAL_SCORE_MISSING); + super(FormErrorProperty.MISSING_TOTAL_SCORE); } } diff --git a/src/main/java/com/bamdoliro/maru/domain/form/exception/error/FormErrorProperty.java b/src/main/java/com/bamdoliro/maru/domain/form/exception/error/FormErrorProperty.java index 308798d8..30e2fe09 100644 --- a/src/main/java/com/bamdoliro/maru/domain/form/exception/error/FormErrorProperty.java +++ b/src/main/java/com/bamdoliro/maru/domain/form/exception/error/FormErrorProperty.java @@ -15,7 +15,7 @@ public enum FormErrorProperty implements ErrorProperty { CANNOT_UPDATE_NOT_REJECTED_FORM(HttpStatus.CONFLICT, "반려된 원서만 수정할 수 있습니다."), INVALID_FORM_STATUS(HttpStatus.CONFLICT, "원서 상태가 유효하지 않습니다."), INVALID_FILE(HttpStatus.BAD_REQUEST, "잘못된 파일입니다."), - TOTAL_SCORE_MISSING(HttpStatus.PRECONDITION_FAILED, "최종 점수가 입력되지 않은 원서가 존재합니다.") + MISSING_TOTAL_SCORE(HttpStatus.PRECONDITION_FAILED, "최종 점수가 입력되지 않은 원서가 존재합니다.") ; private final HttpStatus status; diff --git a/src/test/java/com/bamdoliro/maru/presentation/form/FormControllerTest.java b/src/test/java/com/bamdoliro/maru/presentation/form/FormControllerTest.java index 7f90f05c..1bbacfbf 100644 --- a/src/test/java/com/bamdoliro/maru/presentation/form/FormControllerTest.java +++ b/src/test/java/com/bamdoliro/maru/presentation/form/FormControllerTest.java @@ -4,11 +4,7 @@ import com.bamdoliro.maru.domain.form.domain.Form; import com.bamdoliro.maru.domain.form.domain.type.FormStatus; import com.bamdoliro.maru.domain.form.domain.type.FormType; -import com.bamdoliro.maru.domain.form.exception.CannotUpdateNotRejectedFormException; -import com.bamdoliro.maru.domain.form.exception.FormAlreadySubmittedException; -import com.bamdoliro.maru.domain.form.exception.FormNotFoundException; -import com.bamdoliro.maru.domain.form.exception.InvalidFileException; -import com.bamdoliro.maru.domain.form.exception.InvalidFormStatusException; +import com.bamdoliro.maru.domain.form.exception.*; import com.bamdoliro.maru.domain.user.domain.User; import com.bamdoliro.maru.infrastructure.pdf.exception.FailedToExportPdfException; import com.bamdoliro.maru.infrastructure.s3.dto.response.UploadResponse; @@ -1862,4 +1858,44 @@ class FormControllerTest extends RestDocsTestSupport { verify(queryFormUrlUseCase, times(1)).execute(idList); } + + @Test + void 자동으로_2차_합격_여부를_결정한다() throws Exception { + User user = UserFixture.createAdminUser(); + + given(authenticationArgumentResolver.supportsParameter(any(MethodParameter.class))).willReturn(true); + given(authenticationArgumentResolver.resolveArgument(any(), any(), any(), any())).willReturn(user); + willDoNothing().given(selectSecondPassUseCase).execute(); + + mockMvc.perform(patch("/form/second-round/select") + .header(HttpHeaders.AUTHORIZATION, AuthFixture.createAuthHeader())) + + .andExpect(status().isNoContent()) + + .andDo(restDocs.document( + requestHeaders( + headerWithName(HttpHeaders.AUTHORIZATION).description("Bearer token") + ) + )); + + verify(selectSecondPassUseCase, times(1)).execute(); + } + + @Test + void 자동으로_2차_합격_여부를_결정할_때_최종_점수가_없는_원서가_존재하면_에러가_발생한다() throws Exception { + User user = UserFixture.createAdminUser(); + + given(authenticationArgumentResolver.supportsParameter(any(MethodParameter.class))).willReturn(true); + given(authenticationArgumentResolver.resolveArgument(any(), any(), any(), any())).willReturn(user); + willThrow(new MissingTotalScoreException()).given(selectSecondPassUseCase).execute(); + + mockMvc.perform(patch("/form/second-round/select") + .header(HttpHeaders.AUTHORIZATION, AuthFixture.createAuthHeader())) + + .andExpect(status().isPreconditionFailed()) + + .andDo(restDocs.document()); + + verify(selectSecondPassUseCase, times(1)).execute(); + } } \ No newline at end of file diff --git a/src/test/java/com/bamdoliro/maru/shared/util/ControllerTest.java b/src/test/java/com/bamdoliro/maru/shared/util/ControllerTest.java index 934b9bda..28b464bd 100644 --- a/src/test/java/com/bamdoliro/maru/shared/util/ControllerTest.java +++ b/src/test/java/com/bamdoliro/maru/shared/util/ControllerTest.java @@ -12,32 +12,7 @@ import com.bamdoliro.maru.application.fair.ExportAttendeeListUseCase; import com.bamdoliro.maru.application.fair.QueryFairDetailUseCase; import com.bamdoliro.maru.application.fair.QueryFairListUseCase; -import com.bamdoliro.maru.application.form.ApproveFormUseCase; -import com.bamdoliro.maru.application.form.DownloadSecondRoundScoreFormatUseCase; -import com.bamdoliro.maru.application.form.DraftFormUseCase; -import com.bamdoliro.maru.application.form.ExportFinalPassedFormUseCase; -import com.bamdoliro.maru.application.form.ExportFirstRoundResultUseCase; -import com.bamdoliro.maru.application.form.ExportFormUseCase; -import com.bamdoliro.maru.application.form.ExportResultUseCase; -import com.bamdoliro.maru.application.form.ExportSecondRoundResultUseCase; -import com.bamdoliro.maru.application.form.GenerateAdmissionTicketUseCase; -import com.bamdoliro.maru.application.form.PassOrFailFormUseCase; -import com.bamdoliro.maru.application.form.QueryAllFormUseCase; -import com.bamdoliro.maru.application.form.QueryDraftFormUseCase; -import com.bamdoliro.maru.application.form.QueryFinalFormResultUseCase; -import com.bamdoliro.maru.application.form.QueryFirstFormResultUseCase; -import com.bamdoliro.maru.application.form.QueryFormStatusUseCase; -import com.bamdoliro.maru.application.form.QueryFormUrlUseCase; -import com.bamdoliro.maru.application.form.QueryFormUseCase; -import com.bamdoliro.maru.application.form.QuerySubmittedFormUseCase; -import com.bamdoliro.maru.application.form.ReceiveFormUseCase; -import com.bamdoliro.maru.application.form.RejectFormUseCase; -import com.bamdoliro.maru.application.form.SubmitFinalFormUseCase; -import com.bamdoliro.maru.application.form.SubmitFormUseCase; -import com.bamdoliro.maru.application.form.UpdateFormUseCase; -import com.bamdoliro.maru.application.form.UpdateSecondRoundScoreUseCase; -import com.bamdoliro.maru.application.form.UploadFormUseCase; -import com.bamdoliro.maru.application.form.UploadIdentificationPictureUseCase; +import com.bamdoliro.maru.application.form.*; import com.bamdoliro.maru.application.message.SendMessageUseCase; import com.bamdoliro.maru.application.notice.*; import com.bamdoliro.maru.application.question.CreateQuestionUseCase; @@ -246,6 +221,9 @@ public abstract class ControllerTest { @MockBean protected QueryFormUrlUseCase queryFormUrlUseCase; + @MockBean + protected SelectSecondPassUseCase selectSecondPassUseCase; + @MockBean protected SendMessageUseCase sendMessageUseCase; From 3e005a965129cde1cb46e96516481c4652847870 Mon Sep 17 00:00:00 2001 From: cabbage16 Date: Thu, 11 Jul 2024 15:42:23 +0900 Subject: [PATCH 14/25] =?UTF-8?q?docs(#98):=202=EC=B0=A8=20=ED=95=A9?= =?UTF-8?q?=EA=B2=A9=20=EC=97=AC=EB=B6=80=20=EC=9E=90=EB=8F=99=20=EA=B2=B0?= =?UTF-8?q?=EC=A0=95=20API=20=EB=AC=B8=EC=84=9C=20=EC=9E=91=EC=84=B1=20-?= =?UTF-8?q?=202=EC=B0=A8=20=ED=95=A9=EA=B2=A9=20=EC=97=AC=EB=B6=80?= =?UTF-8?q?=EB=A5=BC=20=EC=9E=90=EB=8F=99=EC=9C=BC=EB=A1=9C=20=EA=B2=B0?= =?UTF-8?q?=EC=A0=95=ED=95=98=EB=8A=94=20API=20=EB=A5=BC=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=ED=96=88=EC=96=B4=EC=9A=94.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/docs/asciidoc/form.adoc | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/docs/asciidoc/form.adoc b/src/docs/asciidoc/form.adoc index 200af395..e7992b68 100644 --- a/src/docs/asciidoc/form.adoc +++ b/src/docs/asciidoc/form.adoc @@ -585,4 +585,24 @@ include::{snippets}/form-controller-test/선택한_원서의_원서url을_조회 ==== 응답 ===== 정상 응답 -include::{snippets}/form-controller-test/선택한_원서의_원서url을_조회한다/http-response.adoc[] \ No newline at end of file +include::{snippets}/form-controller-test/선택한_원서의_원서url을_조회한다/http-response.adoc[] + + + +=== 2차 합격 자동 처리 + +==== 요청 형식 + +===== Request Header +include::{snippets}/form-controller-test/자동으로_2차_합격_여부를_결정한다/request-headers.adoc[] + +==== 요청 +include::{snippets}/form-controller-test/자동으로_2차_합격_여부를_결정한다/http-request.adoc[] + +==== 응답 + +===== 정상 응답 +include::{snippets}/form-controller-test/자동으로_2차_합격_여부를_결정한다/http-response.adoc[] + +===== 최종 점수가 없는 원서가 있을 경우 +include::{snippets}/form-controller-test/자동으로_2차_합격_여부를_결정할_때_최종_점수가_없는_원서가_존재하면_에러가_발생한다/http-response.adoc[] \ No newline at end of file From 4f9d4554291dcb6b429b30cbf77a15cdcc83747b Mon Sep 17 00:00:00 2001 From: cabbage16 Date: Tue, 9 Jul 2024 16:22:25 +0900 Subject: [PATCH 15/25] =?UTF-8?q?feat(#98):=20=EC=B5=9C=EC=A2=85=20?= =?UTF-8?q?=ED=95=A9=EA=B2=A9=20=EC=97=AC=EB=B6=80=20=EA=B2=B0=EC=A0=95=20?= =?UTF-8?q?API=20=EC=9E=91=EC=84=B1=20-=20=EC=96=B4=EB=93=9C=EB=AF=BC?= =?UTF-8?q?=EC=9D=B4=20=EC=B5=9C=EC=A2=85=20=EC=A0=90=EC=88=98=20=EC=88=9C?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=B5=9C=EC=A2=85=20=ED=95=A9=EA=B2=A9=20?= =?UTF-8?q?=EC=97=AC=EB=B6=80=EB=A5=BC=20=EA=B2=B0=EC=A0=95=ED=95=A0=20?= =?UTF-8?q?=EC=88=98=20=EC=9E=88=EC=8A=B5=EB=8B=88=EB=8B=A4.=20-=201?= =?UTF-8?q?=EC=B0=A8=20=ED=95=A9=EA=B2=A9=20=EC=9B=90=EC=84=9C=20=EC=A4=91?= =?UTF-8?q?=20=EC=B5=9C=EC=A2=85=20=EC=A0=90=EC=88=98=EA=B0=80=20=EC=97=86?= =?UTF-8?q?=EB=8A=94=20=EC=9B=90=EC=84=9C=EA=B0=80=20=EC=9E=88=EB=8B=A4?= =?UTF-8?q?=EB=A9=B4=20=EC=98=88=EC=99=B8=EA=B0=80=20=EB=B0=9C=EC=83=9D?= =?UTF-8?q?=ED=95=A9=EB=8B=88=EB=8B=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/exception/TotalScoreMissingException.java | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java diff --git a/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java b/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java new file mode 100644 index 00000000..028d46ff --- /dev/null +++ b/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java @@ -0,0 +1,11 @@ +package com.bamdoliro.maru.domain.form.exception; + +import com.bamdoliro.maru.domain.form.exception.error.FormErrorProperty; +import com.bamdoliro.maru.shared.error.ErrorProperty; +import com.bamdoliro.maru.shared.error.MaruException; + +public class TotalScoreMissingException extends MaruException { + public TotalScoreMissingException() { + super(FormErrorProperty.TOTAL_SCORE_MISSING); + } +} From 1810c793d9af8de784a56cd938ae54870e1033d7 Mon Sep 17 00:00:00 2001 From: cabbage16 Date: Tue, 9 Jul 2024 16:23:03 +0900 Subject: [PATCH 16/25] =?UTF-8?q?refactor(#98):=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20import=20=EB=AC=B8=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../maru/domain/form/exception/TotalScoreMissingException.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java b/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java index 028d46ff..22557233 100644 --- a/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java +++ b/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java @@ -1,7 +1,6 @@ package com.bamdoliro.maru.domain.form.exception; import com.bamdoliro.maru.domain.form.exception.error.FormErrorProperty; -import com.bamdoliro.maru.shared.error.ErrorProperty; import com.bamdoliro.maru.shared.error.MaruException; public class TotalScoreMissingException extends MaruException { From 0c4d1dd6dc84fc5a1246d3769e73e03106554403 Mon Sep 17 00:00:00 2001 From: cabbage16 Date: Fri, 26 Jul 2024 16:46:51 +0900 Subject: [PATCH 17/25] =?UTF-8?q?feat(#98):=20=EC=9B=90=EC=84=9C=20?= =?UTF-8?q?=EC=A0=84=EC=B2=B4=20=EC=A1=B0=ED=9A=8C=20=EC=A0=95=EB=A0=AC=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80=20-=20=EC=A0=95?= =?UTF-8?q?=EB=A0=AC=20=EA=B8=B0=EC=A4=80=EC=9D=84=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?=ED=95=B4=EC=84=9C=20=EC=B5=9C=EC=A2=85=20=EC=A0=90=EC=88=98=20?= =?UTF-8?q?=EC=98=A4=EB=A6=84=EC=B0=A8=EC=88=9C,=20=EB=82=B4=EB=A6=BC?= =?UTF-8?q?=EC=B0=A8=EC=88=9C=EC=9C=BC=EB=A1=9C=20=EC=A0=95=EB=A0=AC?= =?UTF-8?q?=ED=95=A0=20=EC=88=98=20=EC=9E=88=EC=8A=B5=EB=8B=88=EB=8B=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/form/QueryAllFormUseCase.java | 19 ++++++++++++++++--- .../persistence/form/FormRepositoryImpl.java | 17 +++++++++++------ .../presentation/form/FormController.java | 19 +++++++++++++++++-- 3 files changed, 44 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/bamdoliro/maru/application/form/QueryAllFormUseCase.java b/src/main/java/com/bamdoliro/maru/application/form/QueryAllFormUseCase.java index 884bc6c4..7c2067dc 100644 --- a/src/main/java/com/bamdoliro/maru/application/form/QueryAllFormUseCase.java +++ b/src/main/java/com/bamdoliro/maru/application/form/QueryAllFormUseCase.java @@ -1,5 +1,6 @@ package com.bamdoliro.maru.application.form; +import com.bamdoliro.maru.domain.form.domain.Form; import com.bamdoliro.maru.domain.form.domain.type.FormStatus; import com.bamdoliro.maru.domain.form.domain.type.FormType; import com.bamdoliro.maru.infrastructure.persistence.form.FormRepository; @@ -7,6 +8,7 @@ import com.bamdoliro.maru.shared.annotation.UseCase; import lombok.RequiredArgsConstructor; +import java.util.Comparator; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; @@ -17,10 +19,21 @@ public class QueryAllFormUseCase { private final FormRepository formRepository; - public List execute(FormStatus status, FormType.Category category) { - return formRepository.findByStatus(status).stream() + public List execute(FormStatus status, FormType.Category category, String orderBy, String order) { + List forms = new java.util.ArrayList<>(formRepository.findByStatus(status).stream() .filter(form -> Objects.isNull(category) || form.getType().categoryEquals(category)) + .toList()); + + if (orderBy.equals("totalScore")) { + if (order.equals("asc")) { + forms.sort(Comparator.comparing(form -> form.getScore().getTotalScore(), Comparator.naturalOrder())); + } else if (order.equals("desc")) { + forms.sort(Comparator.comparing(form -> form.getScore().getTotalScore())); + } + } + + return forms.stream() .map(FormSimpleResponse::new) .collect(Collectors.toList()); } -} +} \ No newline at end of file diff --git a/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryImpl.java b/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryImpl.java index eaaec14d..f85b96fd 100644 --- a/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryImpl.java +++ b/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryImpl.java @@ -161,14 +161,19 @@ public List findFirstPassedRegularForm() { @Override public List findFirstPassedSupernumeraryForm() { - return List.of(); + return queryFactory + .selectFrom(form) + .where( + form.status.eq(FormStatus.FIRST_PASSED) + .and( + form.type.eq(FormType.SPECIAL_ADMISSION) + .or(form.type.eq(FormType.NATIONAL_VETERANS_EDUCATION)) + ) + ) + .orderBy(form.score.totalScore.desc()) + .fetch(); } -// @Override -// public List findFirstPassedRegularOrSupernumeraryForm() { -// -// } - @Override public List findFirstRoundForm() { return queryFactory diff --git a/src/main/java/com/bamdoliro/maru/presentation/form/FormController.java b/src/main/java/com/bamdoliro/maru/presentation/form/FormController.java index 5983885c..6e8f96c8 100644 --- a/src/main/java/com/bamdoliro/maru/presentation/form/FormController.java +++ b/src/main/java/com/bamdoliro/maru/presentation/form/FormController.java @@ -69,6 +69,7 @@ public class FormController { private final ExportResultUseCase exportResultUseCase; private final PassOrFailFormUseCase passOrFailFormUseCase; private final QueryFormUrlUseCase queryFormUrlUseCase; + private final SelectFirstPassUseCase selectFirstPassUseCase; private final SelectSecondPassUseCase selectSecondPassUseCase; @ResponseStatus(HttpStatus.CREATED) @@ -192,10 +193,12 @@ public ResponseEntity exportForm( public ListCommonResponse getFormList( @AuthenticationPrincipal(authority = Authority.ADMIN) User user, @RequestParam(name = "status", required = false) FormStatus status, - @RequestParam(name = "type", required = false) FormType.Category type + @RequestParam(name = "type", required = false) FormType.Category type, + @RequestParam(name = "order-by", required = false) String orderBy, + @RequestParam(name = "order", required = false) String order ) { return ListCommonResponse.ok( - queryAllFormUseCase.execute(status, type) + queryAllFormUseCase.execute(status, type, orderBy, order) ); } @@ -299,6 +302,18 @@ public ListCommonResponse getFormUrl( ); } + /** + * 테스트용 메서드. 커밋 전에 삭제해야함. + * @param user + */ + @ResponseStatus(HttpStatus.NO_CONTENT) + @PatchMapping("/first-round/select") + public void selectFirstPass( + @AuthenticationPrincipal(authority = Authority.ADMIN) User user + ) { + selectFirstPassUseCase.execute(); + } + @ResponseStatus(HttpStatus.NO_CONTENT) @PatchMapping("/second-round/select") public void selectSecondPass( From d89d25c30ad20eb030395d32755e2a22931061f8 Mon Sep 17 00:00:00 2001 From: cabbage16 Date: Sat, 27 Jul 2024 01:55:41 +0900 Subject: [PATCH 18/25] =?UTF-8?q?refactor(#98):=20=EC=A0=95=EB=A0=AC=20?= =?UTF-8?q?=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=20=EB=B3=80=EA=B2=BD=20-?= =?UTF-8?q?=20=EC=A0=95=EB=A0=AC=20=EA=B8=B0=EC=A4=80=EA=B3=BC=20=EC=A0=95?= =?UTF-8?q?=EB=A0=AC=20=EB=B0=A9=EC=8B=9D=EC=9D=84=20=ED=95=98=EB=82=98?= =?UTF-8?q?=EC=9D=98=20=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=EB=A1=9C=20?= =?UTF-8?q?=ED=95=A9=EC=B3=A4=EC=8A=B5=EB=8B=88=EB=8B=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../maru/application/form/QueryAllFormUseCase.java | 12 +++++------- .../maru/presentation/form/FormController.java | 5 ++--- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/bamdoliro/maru/application/form/QueryAllFormUseCase.java b/src/main/java/com/bamdoliro/maru/application/form/QueryAllFormUseCase.java index 7c2067dc..ad331e60 100644 --- a/src/main/java/com/bamdoliro/maru/application/form/QueryAllFormUseCase.java +++ b/src/main/java/com/bamdoliro/maru/application/form/QueryAllFormUseCase.java @@ -19,17 +19,15 @@ public class QueryAllFormUseCase { private final FormRepository formRepository; - public List execute(FormStatus status, FormType.Category category, String orderBy, String order) { + public List execute(FormStatus status, FormType.Category category, String sort) { List forms = new java.util.ArrayList<>(formRepository.findByStatus(status).stream() .filter(form -> Objects.isNull(category) || form.getType().categoryEquals(category)) .toList()); - if (orderBy.equals("totalScore")) { - if (order.equals("asc")) { - forms.sort(Comparator.comparing(form -> form.getScore().getTotalScore(), Comparator.naturalOrder())); - } else if (order.equals("desc")) { - forms.sort(Comparator.comparing(form -> form.getScore().getTotalScore())); - } + if (sort.equals("total-score-asc")) { + forms.sort(Comparator.comparing(form -> form.getScore().getTotalScore(), Comparator.naturalOrder())); + } else if (sort.equals("total-score-desc")) { + forms.sort(Comparator.comparing(form -> form.getScore().getTotalScore(), Comparator.reverseOrder())); } return forms.stream() diff --git a/src/main/java/com/bamdoliro/maru/presentation/form/FormController.java b/src/main/java/com/bamdoliro/maru/presentation/form/FormController.java index 6e8f96c8..bcc11009 100644 --- a/src/main/java/com/bamdoliro/maru/presentation/form/FormController.java +++ b/src/main/java/com/bamdoliro/maru/presentation/form/FormController.java @@ -194,11 +194,10 @@ public ListCommonResponse getFormList( @AuthenticationPrincipal(authority = Authority.ADMIN) User user, @RequestParam(name = "status", required = false) FormStatus status, @RequestParam(name = "type", required = false) FormType.Category type, - @RequestParam(name = "order-by", required = false) String orderBy, - @RequestParam(name = "order", required = false) String order + @RequestParam(name = "sort", required = false) String sort ) { return ListCommonResponse.ok( - queryAllFormUseCase.execute(status, type, orderBy, order) + queryAllFormUseCase.execute(status, type, sort) ); } From 8f04b8c38366e2f360393733c01649e3d2a0da9d Mon Sep 17 00:00:00 2001 From: cabbage16 Date: Tue, 30 Jul 2024 00:31:59 +0900 Subject: [PATCH 19/25] =?UTF-8?q?test(#98):=20=EC=A0=95=EB=A0=AC=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20UseCaseTest=20=EC=B6=94=EA=B0=80=20-=20?= =?UTF-8?q?=EC=B5=9C=EC=A2=85=20=EC=A0=90=EC=88=98=20=EB=82=B4=EB=A6=BC?= =?UTF-8?q?=EC=B0=A8=EC=88=9C=20=EC=A1=B0=ED=9A=8C=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=EB=A5=BC=20=EB=A7=8C=EB=93=A4=EC=97=88=EC=96=B4?= =?UTF-8?q?=EC=9A=94.=20-=20=EC=B5=9C=EC=A2=85=20=EC=A0=90=EC=88=98=20?= =?UTF-8?q?=EC=98=A4=EB=A6=84=EC=B0=A8=EC=88=9C=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=EB=A5=BC=20=EB=A7=8C=EB=93=A4?= =?UTF-8?q?=EC=97=88=EC=96=B4=EC=9A=94.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/form/QueryAllFormUseCase.java | 12 +-- .../form/QueryAllFormUseCaseTest.java | 87 ++++++++++++++++++- 2 files changed, 90 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/bamdoliro/maru/application/form/QueryAllFormUseCase.java b/src/main/java/com/bamdoliro/maru/application/form/QueryAllFormUseCase.java index ad331e60..64ab4e09 100644 --- a/src/main/java/com/bamdoliro/maru/application/form/QueryAllFormUseCase.java +++ b/src/main/java/com/bamdoliro/maru/application/form/QueryAllFormUseCase.java @@ -20,17 +20,17 @@ public class QueryAllFormUseCase { private final FormRepository formRepository; public List execute(FormStatus status, FormType.Category category, String sort) { - List forms = new java.util.ArrayList<>(formRepository.findByStatus(status).stream() + List formList = new java.util.ArrayList<>(formRepository.findByStatus(status).stream() .filter(form -> Objects.isNull(category) || form.getType().categoryEquals(category)) .toList()); - if (sort.equals("total-score-asc")) { - forms.sort(Comparator.comparing(form -> form.getScore().getTotalScore(), Comparator.naturalOrder())); - } else if (sort.equals("total-score-desc")) { - forms.sort(Comparator.comparing(form -> form.getScore().getTotalScore(), Comparator.reverseOrder())); + if ("total-score-asc".equals(sort)) { + formList.sort(Comparator.comparing(form -> form.getScore().getTotalScore(), Comparator.naturalOrder())); + } else if ("total-score-desc".equals(sort)) { + formList.sort(Comparator.comparing(form -> form.getScore().getTotalScore(), Comparator.reverseOrder())); } - return forms.stream() + return formList.stream() .map(FormSimpleResponse::new) .collect(Collectors.toList()); } diff --git a/src/test/java/com/bamdoliro/maru/application/form/QueryAllFormUseCaseTest.java b/src/test/java/com/bamdoliro/maru/application/form/QueryAllFormUseCaseTest.java index 58dec203..62671975 100644 --- a/src/test/java/com/bamdoliro/maru/application/form/QueryAllFormUseCaseTest.java +++ b/src/test/java/com/bamdoliro/maru/application/form/QueryAllFormUseCaseTest.java @@ -5,12 +5,15 @@ import com.bamdoliro.maru.infrastructure.persistence.form.FormRepository; import com.bamdoliro.maru.presentation.form.dto.response.FormSimpleResponse; import com.bamdoliro.maru.shared.fixture.FormFixture; +import com.bamdoliro.maru.shared.util.RandomUtil; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import java.util.Collections; +import java.util.Comparator; import java.util.List; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -40,7 +43,7 @@ class QueryAllFormUseCaseTest { given(formRepository.findByStatus(null)).willReturn(formList); // when - List returnedFormList = queryAllFormUseCase.execute(null, null); + List returnedFormList = queryAllFormUseCase.execute(null, null, null); // then assertEquals(formList.size(), returnedFormList.size()); @@ -61,7 +64,7 @@ class QueryAllFormUseCaseTest { given(formRepository.findByStatus(null)).willReturn(formList); // when - List returnedFormList = queryAllFormUseCase.execute(null, FormType.Category.SPECIAL); + List returnedFormList = queryAllFormUseCase.execute(null, FormType.Category.SPECIAL, null); // then assertEquals(2, returnedFormList.size()); @@ -82,11 +85,89 @@ class QueryAllFormUseCaseTest { given(formRepository.findByStatus(null)).willReturn(formList); // when - List returnedFormList = queryAllFormUseCase.execute(null, FormType.Category.SOCIAL_INTEGRATION); + List returnedFormList = queryAllFormUseCase.execute(null, FormType.Category.SOCIAL_INTEGRATION, null); // then assertEquals(1, returnedFormList.size()); verify(formRepository, times(1)).findByStatus(null); } + + @Test + void 최종_점수가_높은_순으로_조회한다() { + // given + List formList = List.of( + FormFixture.createForm(FormType.REGULAR), + FormFixture.createForm(FormType.SPECIAL_ADMISSION), + FormFixture.createForm(FormType.MEISTER_TALENT), + FormFixture.createForm(FormType.MULTI_CHILDREN) + ); + + formList.stream() + .filter(form -> form.getType() == FormType.MEISTER_TALENT) + .forEach(form -> form.getScore().updateSecondRoundMeisterScore( + RandomUtil.randomDouble(10, 50), + RandomUtil.randomDouble(10, 50), + RandomUtil.randomDouble(10, 50) + )); + formList.stream() + .filter(form -> form.getType() != FormType.MEISTER_TALENT) + .forEach(form -> form.getScore().updateSecondRoundScore( + RandomUtil.randomDouble(10, 50), + RandomUtil.randomDouble(10, 50) + )); + given(formRepository.findByStatus(null)).willReturn(formList); + + // when + List returnedFormList = queryAllFormUseCase.execute(null, null, "total-score-desc"); + + // then + assertEquals( + Collections.max(formList, Comparator.comparingDouble(form -> form.getScore().getTotalScore())) + .getScore() + .getTotalScore(), + returnedFormList.get(0).getTotalScore() + ); + + verify(formRepository, times(1)).findByStatus(null); + } + + @Test + void 최종_점수가_낮은_순으로_조회한다() { + // given + List formList = List.of( + FormFixture.createForm(FormType.REGULAR), + FormFixture.createForm(FormType.SPECIAL_ADMISSION), + FormFixture.createForm(FormType.MEISTER_TALENT), + FormFixture.createForm(FormType.MULTI_CHILDREN) + ); + + formList.stream() + .filter(form -> form.getType() == FormType.MEISTER_TALENT) + .forEach(form -> form.getScore().updateSecondRoundMeisterScore( + RandomUtil.randomDouble(10, 50), + RandomUtil.randomDouble(10, 50), + RandomUtil.randomDouble(10, 50) + )); + formList.stream() + .filter(form -> form.getType() != FormType.MEISTER_TALENT) + .forEach(form -> form.getScore().updateSecondRoundScore( + RandomUtil.randomDouble(10, 50), + RandomUtil.randomDouble(10, 50) + )); + given(formRepository.findByStatus(null)).willReturn(formList); + + // when + List returnedFormList = queryAllFormUseCase.execute(null, null, "total-score-asc"); + + // then + assertEquals( + Collections.min(formList, Comparator.comparingDouble(form -> form.getScore().getTotalScore())) + .getScore() + .getTotalScore(), + returnedFormList.get(0).getTotalScore() + ); + + verify(formRepository, times(1)).findByStatus(null); + } } \ No newline at end of file From b35dbb8930ca09f4dc1d1df831388c7a5c81aa58 Mon Sep 17 00:00:00 2001 From: cabbage16 Date: Wed, 31 Jul 2024 01:41:17 +0900 Subject: [PATCH 20/25] =?UTF-8?q?fix(#98):=201=EC=B0=A8=ED=95=A9=EA=B2=A9?= =?UTF-8?q?=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=82=AD=EC=A0=9C=20-=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=EC=9A=A9=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=A7=8C=EB=93=A0=201=EC=B0=A8=ED=95=A9=EA=B2=A9=20=EC=9E=90?= =?UTF-8?q?=EB=8F=99=20=EB=A9=94=EC=84=9C=EB=93=9C=EB=A5=BC=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=ED=96=88=EC=96=B4=EC=9A=94.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../maru/presentation/form/FormController.java | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/main/java/com/bamdoliro/maru/presentation/form/FormController.java b/src/main/java/com/bamdoliro/maru/presentation/form/FormController.java index bcc11009..73b74244 100644 --- a/src/main/java/com/bamdoliro/maru/presentation/form/FormController.java +++ b/src/main/java/com/bamdoliro/maru/presentation/form/FormController.java @@ -69,7 +69,6 @@ public class FormController { private final ExportResultUseCase exportResultUseCase; private final PassOrFailFormUseCase passOrFailFormUseCase; private final QueryFormUrlUseCase queryFormUrlUseCase; - private final SelectFirstPassUseCase selectFirstPassUseCase; private final SelectSecondPassUseCase selectSecondPassUseCase; @ResponseStatus(HttpStatus.CREATED) @@ -301,18 +300,6 @@ public ListCommonResponse getFormUrl( ); } - /** - * 테스트용 메서드. 커밋 전에 삭제해야함. - * @param user - */ - @ResponseStatus(HttpStatus.NO_CONTENT) - @PatchMapping("/first-round/select") - public void selectFirstPass( - @AuthenticationPrincipal(authority = Authority.ADMIN) User user - ) { - selectFirstPassUseCase.execute(); - } - @ResponseStatus(HttpStatus.NO_CONTENT) @PatchMapping("/second-round/select") public void selectSecondPass( From ac49ba6e08e8ad4e2fe657c038279336a1e433c1 Mon Sep 17 00:00:00 2001 From: cabbage16 Date: Wed, 31 Jul 2024 01:42:52 +0900 Subject: [PATCH 21/25] =?UTF-8?q?perf(#98):=20=EC=B5=9C=EC=A2=85=EC=A0=90?= =?UTF-8?q?=EC=88=98=EC=88=9C=20=EC=A0=95=EB=A0=AC=20=EC=8B=9C=20=EC=B5=9C?= =?UTF-8?q?=EC=A2=85=20=EC=A0=90=EC=88=98=EA=B0=80=20=EC=97=86=EB=8A=94=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20=EC=98=A4=EB=A5=98=20=EB=B0=9C=EC=83=9D=20?= =?UTF-8?q?-=20=EC=9B=90=EC=84=9C=EB=A5=BC=20=EC=A0=84=EC=B2=B4=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=ED=95=A0=20=EB=95=8C=20=EC=B5=9C=EC=A2=85=20?= =?UTF-8?q?=EC=A0=90=EC=88=98=EC=88=9C=EC=9C=BC=EB=A1=9C=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=ED=95=98=EB=8A=94=EB=8D=B0=20=EC=B5=9C=EC=A2=85?= =?UTF-8?q?=EC=A0=90=EC=88=98=EA=B0=80=20=EC=97=86=EB=8A=94=20=EC=9B=90?= =?UTF-8?q?=EC=84=9C=EA=B0=80=20=EC=9E=88=EB=8B=A4=EB=A9=B4=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=EB=A5=BC=20=EB=B0=9C=EC=83=9D=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=ED=96=88=EC=96=B4=EC=9A=94.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bamdoliro/maru/application/form/QueryAllFormUseCase.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/bamdoliro/maru/application/form/QueryAllFormUseCase.java b/src/main/java/com/bamdoliro/maru/application/form/QueryAllFormUseCase.java index 64ab4e09..179dd360 100644 --- a/src/main/java/com/bamdoliro/maru/application/form/QueryAllFormUseCase.java +++ b/src/main/java/com/bamdoliro/maru/application/form/QueryAllFormUseCase.java @@ -3,6 +3,7 @@ import com.bamdoliro.maru.domain.form.domain.Form; import com.bamdoliro.maru.domain.form.domain.type.FormStatus; import com.bamdoliro.maru.domain.form.domain.type.FormType; +import com.bamdoliro.maru.domain.form.exception.MissingTotalScoreException; import com.bamdoliro.maru.infrastructure.persistence.form.FormRepository; import com.bamdoliro.maru.presentation.form.dto.response.FormSimpleResponse; import com.bamdoliro.maru.shared.annotation.UseCase; @@ -24,6 +25,9 @@ public List execute(FormStatus status, FormType.Category cat .filter(form -> Objects.isNull(category) || form.getType().categoryEquals(category)) .toList()); + if (sort != null && formList.stream().anyMatch(form -> form.getScore().getTotalScore() == null)) { + throw new MissingTotalScoreException(); + } if ("total-score-asc".equals(sort)) { formList.sort(Comparator.comparing(form -> form.getScore().getTotalScore(), Comparator.naturalOrder())); } else if ("total-score-desc".equals(sort)) { From dab02cb69bdd2953774a04b9b07858c3571a3bd9 Mon Sep 17 00:00:00 2001 From: cabbage16 Date: Wed, 31 Jul 2024 03:17:35 +0900 Subject: [PATCH 22/25] =?UTF-8?q?fix:=20Git=20Conflict=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/form/exception/TotalScoreMissingException.java | 2 +- .../bamdoliro/maru/presentation/form/FormControllerTest.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java b/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java index 22557233..9a6e0dfa 100644 --- a/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java +++ b/src/main/java/com/bamdoliro/maru/domain/form/exception/TotalScoreMissingException.java @@ -5,6 +5,6 @@ public class TotalScoreMissingException extends MaruException { public TotalScoreMissingException() { - super(FormErrorProperty.TOTAL_SCORE_MISSING); + super(FormErrorProperty.MISSING_TOTAL_SCORE); } } diff --git a/src/test/java/com/bamdoliro/maru/presentation/form/FormControllerTest.java b/src/test/java/com/bamdoliro/maru/presentation/form/FormControllerTest.java index 1bbacfbf..96dbd01f 100644 --- a/src/test/java/com/bamdoliro/maru/presentation/form/FormControllerTest.java +++ b/src/test/java/com/bamdoliro/maru/presentation/form/FormControllerTest.java @@ -1348,7 +1348,7 @@ class FormControllerTest extends RestDocsTestSupport { given(authenticationArgumentResolver.supportsParameter(any(MethodParameter.class))).willReturn(true); given(authenticationArgumentResolver.resolveArgument(any(), any(), any(), any())).willReturn(user); - given(queryAllFormUseCase.execute(FormStatus.SUBMITTED, FormType.Category.REGULAR)).willReturn(responseList); + given(queryAllFormUseCase.execute(FormStatus.SUBMITTED, FormType.Category.REGULAR, null)).willReturn(responseList); mockMvc.perform(get("/form") .param("status", FormStatus.SUBMITTED.name()) @@ -1374,7 +1374,7 @@ class FormControllerTest extends RestDocsTestSupport { ) )); - verify(queryAllFormUseCase, times(1)).execute(FormStatus.SUBMITTED, FormType.Category.REGULAR); + verify(queryAllFormUseCase, times(1)).execute(FormStatus.SUBMITTED, FormType.Category.REGULAR, null); } @Test From cc6f9b95e0b8d1eb9076be6c25ca262b91277852 Mon Sep 17 00:00:00 2001 From: cabbage16 Date: Wed, 31 Jul 2024 03:43:20 +0900 Subject: [PATCH 23/25] =?UTF-8?q?refactor:=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=BB=A8=EB=B2=A4=EC=85=98=20=EC=A4=80=EC=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../persistence/form/FormRepositoryImpl.java | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryImpl.java b/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryImpl.java index f85b96fd..2d86f610 100644 --- a/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryImpl.java +++ b/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryImpl.java @@ -84,9 +84,7 @@ public List findReceivedSpecialForm() { .and(form.type.eq(FormType.SPECIAL_ADMISSION).not()) ) ) - .orderBy( - form.score.firstRoundScore.desc() - ) + .orderBy(form.score.firstRoundScore.desc()) .fetch(); } @@ -101,9 +99,7 @@ public List findReceivedRegularForm() { .or(form.changedToRegular.isTrue()) ) ) - .orderBy( - form.score.firstRoundScore.desc() - ) + .orderBy(form.score.firstRoundScore.desc()) .fetch(); } @@ -118,9 +114,7 @@ public List findReceivedSupernumeraryForm() { .or(form.type.eq(FormType.NATIONAL_VETERANS_EDUCATION)) ) ) - .orderBy( - form.score.firstRoundScore.desc() - ) + .orderBy(form.score.firstRoundScore.desc()) .fetch(); } @@ -136,9 +130,7 @@ public List findFirstPassedSpecialForm() { .and(form.type.eq(FormType.SPECIAL_ADMISSION).not()) ) ) - .orderBy( - form.score.totalScore.desc() - ) + .orderBy(form.score.totalScore.desc()) .fetch(); } @@ -153,9 +145,7 @@ public List findFirstPassedRegularForm() { .or(form.changedToRegular.isTrue()) ) ) - .orderBy( - form.score.totalScore.desc() - ) + .orderBy(form.score.totalScore.desc()) .fetch(); } From 2f1b285442e057214ebbef301e21f9cfd6041e2f Mon Sep 17 00:00:00 2001 From: cabbage16 Date: Mon, 5 Aug 2024 22:48:51 +0900 Subject: [PATCH 24/25] =?UTF-8?q?fix:=20FormErrorProperty=20=EC=BD=A4?= =?UTF-8?q?=EB=A7=88=20=ED=95=B4=EA=B2=B0=20-=20=EB=92=A4=EC=97=90=20?= =?UTF-8?q?=EC=BD=A4=EB=A7=88=EA=B0=80=20=EC=97=86=EC=96=B4=EC=84=9C=20enu?= =?UTF-8?q?m=20=EC=97=90=EC=84=9C=20=EB=B0=9C=EC=83=9D=ED=95=9C=20?= =?UTF-8?q?=EB=AC=B8=EC=A0=9C=EB=A5=BC=20=ED=95=B4=EA=B2=B0=ED=96=88?= =?UTF-8?q?=EC=96=B4=EC=9A=94.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../maru/domain/form/exception/error/FormErrorProperty.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/bamdoliro/maru/domain/form/exception/error/FormErrorProperty.java b/src/main/java/com/bamdoliro/maru/domain/form/exception/error/FormErrorProperty.java index 6c2ce013..973903e0 100644 --- a/src/main/java/com/bamdoliro/maru/domain/form/exception/error/FormErrorProperty.java +++ b/src/main/java/com/bamdoliro/maru/domain/form/exception/error/FormErrorProperty.java @@ -15,7 +15,7 @@ public enum FormErrorProperty implements ErrorProperty { CANNOT_UPDATE_NOT_REJECTED_FORM(HttpStatus.CONFLICT, "반려된 원서만 수정할 수 있습니다."), INVALID_FORM_STATUS(HttpStatus.CONFLICT, "원서 상태가 유효하지 않습니다."), INVALID_FILE(HttpStatus.BAD_REQUEST, "잘못된 파일입니다."), - MISSING_TOTAL_SCORE(HttpStatus.PRECONDITION_FAILED, "최종 점수가 입력되지 않은 원서가 존재합니다.") + MISSING_TOTAL_SCORE(HttpStatus.PRECONDITION_FAILED, "최종 점수가 입력되지 않은 원서가 존재합니다."), WRONG_SCORE(HttpStatus.BAD_REQUEST, "점수 범위를 초과했습니다."), ; From 95dcad5f25b139c888ac887992aa8f9ee4da4bba Mon Sep 17 00:00:00 2001 From: cabbage16 Date: Tue, 3 Sep 2024 16:07:19 +0900 Subject: [PATCH 25/25] =?UTF-8?q?test(#98):=20SelectSecondPassUseCaseTest?= =?UTF-8?q?=20-=202=EC=B0=A8=20=ED=95=A9=EA=B2=A9=20=EC=9E=90=EB=8F=99?= =?UTF-8?q?=ED=99=94=20=EC=8A=A4=ED=94=84=EB=A7=81=20=ED=86=B5=ED=95=A9=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=EB=A5=BC=20=EC=9E=91=EC=84=B1?= =?UTF-8?q?=ED=96=88=EC=96=B4=EC=9A=94.=20-=20=EC=8A=A4=ED=94=84=EB=A7=81?= =?UTF-8?q?=20=EB=B6=80=ED=8A=B8=20=ED=85=8C=EC=8A=A4=ED=8A=B8=EB=A5=BC=20?= =?UTF-8?q?=EC=9C=84=ED=95=B4=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=ED=95=84=EC=9D=B4=20=EC=9E=88=EB=8A=94=20application.?= =?UTF-8?q?yml=EC=9D=84=20=EB=B6=84=EB=A6=AC=ED=95=98=EC=97=AC=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=ED=96=88=EC=96=B4=EC=9A=94.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/SelectSecondPassUseCaseTest.java | 100 ++++++++++++++++++ .../maru/shared/fixture/FormFixture.java | 2 +- src/test/resources/application.yml | 63 +++++++++++ 3 files changed, 164 insertions(+), 1 deletion(-) create mode 100644 src/test/java/com/bamdoliro/maru/application/form/SelectSecondPassUseCaseTest.java create mode 100644 src/test/resources/application.yml diff --git a/src/test/java/com/bamdoliro/maru/application/form/SelectSecondPassUseCaseTest.java b/src/test/java/com/bamdoliro/maru/application/form/SelectSecondPassUseCaseTest.java new file mode 100644 index 00000000..e18956d3 --- /dev/null +++ b/src/test/java/com/bamdoliro/maru/application/form/SelectSecondPassUseCaseTest.java @@ -0,0 +1,100 @@ +package com.bamdoliro.maru.application.form; + +import com.bamdoliro.maru.domain.form.domain.Form; +import com.bamdoliro.maru.domain.form.domain.type.FormStatus; +import com.bamdoliro.maru.domain.form.service.AssignExaminationNumberService; +import com.bamdoliro.maru.domain.form.service.CalculateFormScoreService; +import com.bamdoliro.maru.domain.user.domain.User; +import com.bamdoliro.maru.infrastructure.persistence.form.FormRepository; +import com.bamdoliro.maru.infrastructure.persistence.user.UserRepository; +import com.bamdoliro.maru.shared.constants.FixedNumber; +import com.bamdoliro.maru.shared.fixture.FormFixture; +import com.bamdoliro.maru.shared.fixture.UserFixture; +import com.bamdoliro.maru.shared.util.RandomUtil; +import lombok.extern.slf4j.Slf4j; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; + +import java.util.Comparator; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +@Disabled +@Slf4j +@ActiveProfiles("test") +@SpringBootTest +public class SelectSecondPassUseCaseTest { + + @Autowired + private SelectSecondPassUseCase selectSecondPassUseCase; + + @Autowired + private SelectFirstPassUseCase selectFirstPassUseCase; + + @Autowired + private UserRepository userRepository; + + @Autowired + private FormRepository formRepository; + + @Autowired + private CalculateFormScoreService calculateFormScoreService; + + @Autowired + private AssignExaminationNumberService assignExaminationNumberService; + + @BeforeEach + void setUp() { + List userList = userRepository.saveAll( + UserFixture.generateUserList(FixedNumber.TOTAL * 2) + ); + List formList = FormFixture.generateFormList(userList); + formList.forEach(form -> { + assignExaminationNumberService.execute(form); + form.receive(); + calculateFormScoreService.execute(form); + formRepository.save(form); + }); + selectFirstPassUseCase.execute(); + List firstPassedFormList = formRepository.findByStatus(FormStatus.FIRST_PASSED); + firstPassedFormList.forEach(form -> { + if (form.getType().isMeister()) { + form.getScore().updateSecondRoundMeisterScore(RandomUtil.randomDouble(0, 100), RandomUtil.randomDouble(0, 100), RandomUtil.randomDouble(0, 100)); + } else { + form.getScore().updateSecondRoundScore(RandomUtil.randomDouble(0, 100), RandomUtil.randomDouble(0, 100)); + } + formRepository.save(form); + }); + } + + @Test + void 정상적으로_2차전형_합격자를_선발한다() { + selectSecondPassUseCase.execute(); + + Comparator comparator = Comparator + .comparing(Form::getType) + .thenComparing(form -> form.getScore().getTotalScore()); + + List formList = formRepository.findAll() + .stream() + .filter(form -> form.isPassedNow() || form.isFailedNow()) + .sorted(comparator) + .toList(); + + formList.forEach(form -> { + log.info("===================="); + log.info("id: {}", form.getId()); + log.info("examinationNumber: {}", form.getExaminationNumber()); + log.info("type: {}", form.getType()); + log.info("score: {}", form.getScore().getTotalScore()); + log.info("status: {}", form.getStatus()); + }); + int passedFormCount = (int)formList.stream().filter(Form::isPassedNow).count(); + assertEquals(FixedNumber.TOTAL, passedFormCount); + } +} diff --git a/src/test/java/com/bamdoliro/maru/shared/fixture/FormFixture.java b/src/test/java/com/bamdoliro/maru/shared/fixture/FormFixture.java index 908a2bce..5c6aebb9 100644 --- a/src/test/java/com/bamdoliro/maru/shared/fixture/FormFixture.java +++ b/src/test/java/com/bamdoliro/maru/shared/fixture/FormFixture.java @@ -326,7 +326,7 @@ private static AchievementLevel random3AchievementLevel() { } private static FormType randomFormType() { - FormType[] values = {FormType.REGULAR, FormType.REGULAR, FormType.REGULAR, FormType.REGULAR, FormType.MEISTER_TALENT, FormType.MEISTER_TALENT, FormType.MEISTER_TALENT, FormType.MEISTER_TALENT, FormType.ONE_PARENT, FormType.MULTI_CHILDREN, FormType.SPECIAL_ADMISSION}; + FormType[] values = {FormType.REGULAR, FormType.REGULAR, FormType.REGULAR, FormType.REGULAR, FormType.MEISTER_TALENT, FormType.MEISTER_TALENT, FormType.MEISTER_TALENT, FormType.MEISTER_TALENT, FormType.ONE_PARENT, FormType.MULTI_CHILDREN}; return values[new Random().nextInt(values.length)]; } diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml new file mode 100644 index 00000000..47349d00 --- /dev/null +++ b/src/test/resources/application.yml @@ -0,0 +1,63 @@ +spring: + profiles: + active: test + + data: + redis: + host:localhost + port:6379 + timeout:6 + h2: + console: + enabled: true + path: /h2-console + datasource: + driver-class-name: org.h2.Driver + url: jdbc:h2:mem:db;MODE=MYSQL + username: sa + password: + jpa: + generate-ddl: 'true' + hibernate: + ddl-auto: create + properties: + hibernate: + format_sql: true + use_sql_comments: true + + + cloud: + aws: + s3: + bucket: ${BUCKET_NAME} + stack: + auto: false + region: + static: ${S3_REGION} + credentials: + instance-profile: true + access-key: ${S3_ACCESS_KEY} + secret-key: ${S3_SECRET_KEY} + + logging: + level: + com.amazonaws.util.EC2MetadataUtils: error + + servlet: + multipart: + max-file-size: 10MB + +jwt: + refresh-expiration-time: 1296000000 # 15일 + access-expiration-time: 3600000 # 1시간 + prefix: Bearer + secret-key: ${JWT_SECRET} + +neis: + key: ${NEIS_KEY} + +message: + api-key: ${MESSAGE_API_KEY} + api-secret: ${MESSAGE_API_SECRET} + api-domain: ${MESSAGE_API_DOMAIN} + from: ${MESSAGE_FROM} \ No newline at end of file