From 9d5791adbb71d38316319a59c49e754667e09e2f Mon Sep 17 00:00:00 2001 From: jyj1289 Date: Mon, 15 Jul 2024 09:23:18 +0900 Subject: [PATCH 1/7] =?UTF-8?q?feat(#107):=20EmptyScoreException=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20-=202=EC=B0=A8=EC=A0=84=ED=98=95=20?= =?UTF-8?q?=EC=A0=90=EC=88=98=EB=A5=BC=20=EC=9E=85=EB=A0=A5=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EC=9D=84=20=EB=95=8C=20=EB=B0=9C=EC=83=9D?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EC=98=88=EC=99=B8=EB=A5=BC=20=EB=A7=8C?= =?UTF-8?q?=EB=93=A4=EC=97=88=EC=96=B4=EC=9A=94.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/exception/error/EmptyScoreException.java | 10 ++++++++++ .../domain/form/exception/error/FormErrorProperty.java | 1 + 2 files changed, 11 insertions(+) create mode 100644 src/main/java/com/bamdoliro/maru/domain/form/exception/error/EmptyScoreException.java diff --git a/src/main/java/com/bamdoliro/maru/domain/form/exception/error/EmptyScoreException.java b/src/main/java/com/bamdoliro/maru/domain/form/exception/error/EmptyScoreException.java new file mode 100644 index 00000000..a85d7436 --- /dev/null +++ b/src/main/java/com/bamdoliro/maru/domain/form/exception/error/EmptyScoreException.java @@ -0,0 +1,10 @@ +package com.bamdoliro.maru.domain.form.exception.error; + +import com.bamdoliro.maru.shared.error.MaruException; + +public class EmptyScoreException extends MaruException { + + public EmptyScoreException() { + super(FormErrorProperty.EMPTY_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 99af1e5f..059d2a3c 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, "잘못된 파일입니다."), + EMPTY_SCORE(HttpStatus.BAD_REQUEST, "점수가 비어있습니다."), ; private final HttpStatus status; From 66b57122a932526d2c6e04ee7ee9bc4d78f20702 Mon Sep 17 00:00:00 2001 From: jyj1289 Date: Mon, 15 Jul 2024 09:46:48 +0900 Subject: [PATCH 2/7] =?UTF-8?q?perf(#107):=20=EC=97=91=EC=85=80=20?= =?UTF-8?q?=EC=9D=91=EC=8B=9C=EC=97=AC=EB=B6=80=20=ED=95=A8=EC=88=98=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20-=20=EC=84=A0=EC=83=9D=EB=8B=98=EB=93=A4?= =?UTF-8?q?=EC=9D=B4=20=EC=8B=A4=EC=88=98=EB=A1=9C=20=EC=A0=90=EC=88=98?= =?UTF-8?q?=EB=9E=80=EC=9D=84=20=EB=B9=84=EC=96=B4=EB=86=93=EC=95=98?= =?UTF-8?q?=EC=9D=84=20=EB=95=8C=20=EA=B2=80=EC=A6=9D=EC=9D=84=20=ED=95=98?= =?UTF-8?q?=EA=B8=B0=20=EC=9C=84=ED=95=B4=EC=84=9C=20'=EB=B6=88=EC=B0=B8'?= =?UTF-8?q?=EC=9D=B4=EB=9D=BC=EB=8A=94=20=ED=82=A4=EC=9B=8C=EB=93=9C?= =?UTF-8?q?=EB=A5=BC=20=EC=A0=81=EC=96=B4=EC=95=BC=20=EC=9D=91=EC=8B=9C?= =?UTF-8?q?=EC=97=AC=EB=B6=80=EA=B0=80=20=EA=B1=B0=EC=A7=93=EC=9D=B4=20?= =?UTF-8?q?=EB=82=98=EC=98=A4=EB=8A=94=20=EA=B2=83=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=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/DownloadSecondRoundScoreFormatUseCase.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/bamdoliro/maru/application/form/DownloadSecondRoundScoreFormatUseCase.java b/src/main/java/com/bamdoliro/maru/application/form/DownloadSecondRoundScoreFormatUseCase.java index 2376ad7b..771d388d 100644 --- a/src/main/java/com/bamdoliro/maru/application/form/DownloadSecondRoundScoreFormatUseCase.java +++ b/src/main/java/com/bamdoliro/maru/application/form/DownloadSecondRoundScoreFormatUseCase.java @@ -61,7 +61,8 @@ public Resource execute() throws IOException { Cell showCell = row.createCell(6); showCell.setCellStyle(cellStyle); - showCell.setCellFormula(String.format("IF(C%1$d=\"마이스터인재전형\", IF(OR(ISBLANK(D%1$d), ISBLANK(E%1$d), ISBLANK(F%1$d)), FALSE, TRUE), IF(OR(ISBLANK(D%1$d), ISBLANK(E%1$d)), FALSE, TRUE))", xlsxIndex)); + showCell.setCellFormula(String.format("IF(C%1$d=\"마이스터인재전형\", IF(OR(D%1$d=\"불참\", E%1$d=\"불참\", F%1$d=\"불참\"), FALSE, TRUE), IF(OR(D%1$d=\"불참\", E%1$d=\"불참\"), FALSE, TRUE))", xlsxIndex)); + } return xlsxService.convertToByteArrayResource(workbook); From 031044b57c0bc0deeb487a6955f8c6f41b3eaab8 Mon Sep 17 00:00:00 2001 From: jyj1289 Date: Mon, 15 Jul 2024 10:38:24 +0900 Subject: [PATCH 3/7] =?UTF-8?q?perf(#107):=20EmptyScoreException=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=20-=20=EC=A0=90=EC=88=98=EA=B0=80=20?= =?UTF-8?q?=EB=B9=84=EC=96=B4=EC=9E=88=EB=8A=94=20=EC=98=88=EC=99=B8?= =?UTF-8?q?=EB=8A=94=20=EC=9D=B4=EB=AF=B8=20=EC=B2=98=EB=A6=AC=EB=90=98?= =?UTF-8?q?=EA=B3=A0=20=EC=9E=88=EA=B8=B0=20=EB=95=8C=EB=AC=B8=EC=97=90=20?= =?UTF-8?q?=EA=B5=B3=EC=9D=B4=20=EC=98=88=EC=99=B8=EB=A5=BC=20=EB=A7=8C?= =?UTF-8?q?=EB=93=A4=20=ED=95=84=EC=9A=94=EA=B0=80=20=EC=97=86=EB=8B=A4?= =?UTF-8?q?=EA=B3=A0=20=ED=8C=90=EB=8B=A8=EB=90=98=EC=96=B4=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 --- .../form/exception/error/EmptyScoreException.java | 10 ---------- .../domain/form/exception/error/FormErrorProperty.java | 1 - 2 files changed, 11 deletions(-) delete mode 100644 src/main/java/com/bamdoliro/maru/domain/form/exception/error/EmptyScoreException.java diff --git a/src/main/java/com/bamdoliro/maru/domain/form/exception/error/EmptyScoreException.java b/src/main/java/com/bamdoliro/maru/domain/form/exception/error/EmptyScoreException.java deleted file mode 100644 index a85d7436..00000000 --- a/src/main/java/com/bamdoliro/maru/domain/form/exception/error/EmptyScoreException.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.bamdoliro.maru.domain.form.exception.error; - -import com.bamdoliro.maru.shared.error.MaruException; - -public class EmptyScoreException extends MaruException { - - public EmptyScoreException() { - super(FormErrorProperty.EMPTY_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 059d2a3c..99af1e5f 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,6 @@ public enum FormErrorProperty implements ErrorProperty { CANNOT_UPDATE_NOT_REJECTED_FORM(HttpStatus.CONFLICT, "반려된 원서만 수정할 수 있습니다."), INVALID_FORM_STATUS(HttpStatus.CONFLICT, "원서 상태가 유효하지 않습니다."), INVALID_FILE(HttpStatus.BAD_REQUEST, "잘못된 파일입니다."), - EMPTY_SCORE(HttpStatus.BAD_REQUEST, "점수가 비어있습니다."), ; private final HttpStatus status; From 68e43115a5c34ff756778212e391dc5515567852 Mon Sep 17 00:00:00 2001 From: jyj1289 Date: Sun, 21 Jul 2024 17:53:37 +0900 Subject: [PATCH 4/7] =?UTF-8?q?feat(#107):=20=EC=A0=90=EC=88=98=EA=B2=80?= =?UTF-8?q?=EC=A6=9D=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80=20-=20?= =?UTF-8?q?=EC=84=A0=EC=83=9D=EB=8B=98=EB=93=A4=EC=9D=B4=20=EC=A0=90?= =?UTF-8?q?=EC=88=98=EB=B2=94=EC=9C=84=EB=A5=BC=20=EC=B4=88=EA=B3=BC?= =?UTF-8?q?=ED=95=B4=EC=84=9C=20=EC=9E=85=EB=A0=A5=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EA=B2=83=EC=9D=84=20=EB=B0=A9=EC=A7=80=ED=95=98=EA=B8=B0=20?= =?UTF-8?q?=EC=9C=84=ED=95=9C=20=EA=B8=B0=EB=8A=A5=EC=9D=84=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 --- .../form/UpdateSecondRoundScoreUseCase.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/com/bamdoliro/maru/application/form/UpdateSecondRoundScoreUseCase.java b/src/main/java/com/bamdoliro/maru/application/form/UpdateSecondRoundScoreUseCase.java index 11c2afd5..618031d1 100644 --- a/src/main/java/com/bamdoliro/maru/application/form/UpdateSecondRoundScoreUseCase.java +++ b/src/main/java/com/bamdoliro/maru/application/form/UpdateSecondRoundScoreUseCase.java @@ -4,6 +4,7 @@ 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.InvalidFileException; +import com.bamdoliro.maru.domain.form.exception.WrongScoreException; import com.bamdoliro.maru.infrastructure.persistence.form.FormRepository; import com.bamdoliro.maru.shared.annotation.UseCase; import lombok.AllArgsConstructor; @@ -89,6 +90,20 @@ private void validateRow(Row row) { )) { throw new InvalidFileException(); } + + if (isShow && + ((row.getCell(2).getStringCellValue().equals("마이스터인재전형") && + ((row.getCell(3).getNumericCellValue() > 120 || row.getCell(4).getNumericCellValue() > 40 || row.getCell(5).getNumericCellValue() > 80) || + (row.getCell(3).getNumericCellValue() < 0 || row.getCell(4).getNumericCellValue() < 0 || row.getCell(5).getNumericCellValue() < 0))) || + (row.getCell(2).getStringCellValue().equals("사회통합전형") && + ((row.getCell(3).getNumericCellValue() > 200 || row.getCell(4).getNumericCellValue() > 40) || + (row.getCell(3).getNumericCellValue() < 0 || row.getCell(4).getNumericCellValue() < 0))) || + (!row.getCell(2).getStringCellValue().equals("마이스터인재전형") && + !row.getCell(2).getStringCellValue().equals("사회통합전형") && + ((row.getCell(3).getNumericCellValue() > 120 || row.getCell(4).getNumericCellValue() > 40) || + (row.getCell(3).getNumericCellValue() < 0 || row.getCell(4).getNumericCellValue() < 0))))) { + throw new WrongScoreException(); + } } private FormType.Category getFormType(String description) { From 6ebc5e4d54d2cb1a0adb1003a8aa79af5003a599 Mon Sep 17 00:00:00 2001 From: jyj1289 Date: Sun, 21 Jul 2024 17:53:53 +0900 Subject: [PATCH 5/7] =?UTF-8?q?feat(#107):=20=EC=A0=90=EC=88=98=20?= =?UTF-8?q?=EB=B2=94=EC=9C=84=20=EC=B4=88=EA=B3=BC=20=EC=98=88=EC=99=B8=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/form/exception/WrongScoreException.java | 11 +++++++++++ .../form/exception/error/FormErrorProperty.java | 1 + 2 files changed, 12 insertions(+) create mode 100644 src/main/java/com/bamdoliro/maru/domain/form/exception/WrongScoreException.java diff --git a/src/main/java/com/bamdoliro/maru/domain/form/exception/WrongScoreException.java b/src/main/java/com/bamdoliro/maru/domain/form/exception/WrongScoreException.java new file mode 100644 index 00000000..d2a620ba --- /dev/null +++ b/src/main/java/com/bamdoliro/maru/domain/form/exception/WrongScoreException.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.MaruException; + +public class WrongScoreException extends MaruException { + + public WrongScoreException() { + super(FormErrorProperty.WRONG_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 99af1e5f..73d3f4b7 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, "잘못된 파일입니다."), + WRONG_SCORE(HttpStatus.BAD_REQUEST, "점수 범위를 초과했습니다."), ; private final HttpStatus status; From 6a0fb9071798f0f81be14bbdfdaf180192b89aa7 Mon Sep 17 00:00:00 2001 From: jyj1289 Date: Sun, 21 Jul 2024 17:54:26 +0900 Subject: [PATCH 6/7] =?UTF-8?q?test(#107):=20=EC=A0=90=EC=88=98=20?= =?UTF-8?q?=EB=B2=94=EC=9C=84=20=EC=98=A4=EB=A5=98=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=B6=94=EA=B0=80=20-=20=EC=A0=90=EC=88=98?= =?UTF-8?q?=EA=B0=80=20=EB=B2=94=EC=9C=84=EB=A5=BC=20=EC=B4=88=EA=B3=BC?= =?UTF-8?q?=ED=96=88=EC=9D=84=20=EB=95=8C=20=EC=98=A4=EB=A5=98=EA=B0=80=20?= =?UTF-8?q?=EB=B0=9C=EC=83=9D=ED=95=98=EB=8A=94=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=EB=A5=BC=20=EC=B6=94=EA=B0=80=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 --- .../presentation/form/FormControllerTest.java | 32 ++++++++++++++++--- 1 file changed, 27 insertions(+), 5 deletions(-) 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..5b7ecbeb 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.InvalidFromStatusException; +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; @@ -1635,6 +1631,32 @@ class FormControllerTest extends RestDocsTestSupport { verify(updateSecondRoundScoreUseCase, times(1)).execute(any(MultipartFile.class)); } + @Test + void 입력한_2차_전형_점수가_범위를_초과한_경우_에러가_발생한다() throws Exception { + User user = UserFixture.createAdminUser(); + MockMultipartFile file = new MockMultipartFile( + "xlsx", + "2차전형점수양식.xlsx", + String.valueOf(MediaType.parseMediaType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")), + "<>".getBytes() + ); + + given(authenticationArgumentResolver.supportsParameter(any(MethodParameter.class))).willReturn(true); + given(authenticationArgumentResolver.resolveArgument(any(), any(), any(), any())).willReturn(user); + doThrow(new WrongScoreException()).when(updateSecondRoundScoreUseCase).execute(any(MultipartFile.class)); + + mockMvc.perform(multipartPatch("/form/second-round/score") + .file(file) + .header(HttpHeaders.AUTHORIZATION, AuthFixture.createAuthHeader()) + .contentType(MediaType.MULTIPART_FORM_DATA)) + + .andExpect(status().isBadRequest()) + + .andDo(restDocs.document()); + + verify(updateSecondRoundScoreUseCase, times(1)).execute(any(MultipartFile.class)); + } + @Test void 정상적으로_최종_합격자를_다운로드한다() throws Exception { User user = UserFixture.createAdminUser(); From c7012c21b0b64eefd781229a42b5ed2d5d0839e0 Mon Sep 17 00:00:00 2001 From: jyj1289 Date: Sun, 21 Jul 2024 17:56:07 +0900 Subject: [PATCH 7/7] =?UTF-8?q?docs(#107):=20=EC=A0=90=EC=88=98=20?= =?UTF-8?q?=EB=B2=94=EC=9C=84=20=EC=98=A4=EB=A5=98=20=EB=B0=9C=EC=83=9D?= =?UTF-8?q?=EC=8B=9C=20response=20=EB=82=B4=EC=9A=A9=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/docs/asciidoc/form.adoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/docs/asciidoc/form.adoc b/src/docs/asciidoc/form.adoc index 200af395..8e7c77d7 100644 --- a/src/docs/asciidoc/form.adoc +++ b/src/docs/asciidoc/form.adoc @@ -470,6 +470,8 @@ include::{snippets}/form-controller-test/정상적으로_2차_전형_점수를_ ===== 파일 양식이 잘못된 경우 include::{snippets}/form-controller-test/잘못된_양식의_2차_전형_점수를_입력하면_에러가_발생한다/http-response.adoc[] +===== 입력한 점수가 범위를 초과한 경우 +include::{snippets}/form-controller-test/입력한_2차_전형_점수가_범위를_초과한_경우_에러가_발생한다/http-response.adoc[] === 최종 합격자 명단 다운로드