From daa9cd8f1ca4ad3656071918ca4210b098b4a6a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=89=E1=85=B5=E1=86=AB=E1=84=92=E1=85=B4=E1=84=89?= =?UTF-8?q?=E1=85=A5=E1=86=BC?= Date: Thu, 10 Oct 2024 23:55:04 +0900 Subject: [PATCH] =?UTF-8?q?fix(oneseo):=20=ED=8F=89=EA=B0=80=EC=A0=90?= =?UTF-8?q?=EC=88=98=20validate=20dto=20valid=20=EC=96=B4=EB=85=B8?= =?UTF-8?q?=ED=85=8C=EC=9D=B4=EC=85=98=EC=9C=BC=EB=A1=9C=20=EA=B2=80?= =?UTF-8?q?=EC=A6=9D=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../oneseo/dto/request/AptitudeEvaluationScoreReqDto.java | 4 ++++ .../domain/oneseo/dto/request/InterviewScoreReqDto.java | 4 ++++ .../service/ModifyAptitudeEvaluationScoreService.java | 4 ---- .../oneseo/service/ModifyInterviewScoreService.java | 3 +-- .../hellogsmv3/domain/oneseo/service/OneseoService.java | 8 -------- 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/main/java/team/themoment/hellogsmv3/domain/oneseo/dto/request/AptitudeEvaluationScoreReqDto.java b/src/main/java/team/themoment/hellogsmv3/domain/oneseo/dto/request/AptitudeEvaluationScoreReqDto.java index e70c187b..cdd7ca0d 100644 --- a/src/main/java/team/themoment/hellogsmv3/domain/oneseo/dto/request/AptitudeEvaluationScoreReqDto.java +++ b/src/main/java/team/themoment/hellogsmv3/domain/oneseo/dto/request/AptitudeEvaluationScoreReqDto.java @@ -1,11 +1,15 @@ package team.themoment.hellogsmv3.domain.oneseo.dto.request; +import jakarta.validation.constraints.DecimalMax; +import jakarta.validation.constraints.DecimalMin; import jakarta.validation.constraints.NotNull; import java.math.BigDecimal; public record AptitudeEvaluationScoreReqDto( @NotNull + @DecimalMin(value = "0.0", message = "0점 이상이여야 합니다.") + @DecimalMax(value = "100.0", message = "100점 이하여야 합니다.") BigDecimal aptitudeEvaluationScore ) { } diff --git a/src/main/java/team/themoment/hellogsmv3/domain/oneseo/dto/request/InterviewScoreReqDto.java b/src/main/java/team/themoment/hellogsmv3/domain/oneseo/dto/request/InterviewScoreReqDto.java index 900c8c1c..43a99045 100644 --- a/src/main/java/team/themoment/hellogsmv3/domain/oneseo/dto/request/InterviewScoreReqDto.java +++ b/src/main/java/team/themoment/hellogsmv3/domain/oneseo/dto/request/InterviewScoreReqDto.java @@ -1,11 +1,15 @@ package team.themoment.hellogsmv3.domain.oneseo.dto.request; +import jakarta.validation.constraints.DecimalMax; +import jakarta.validation.constraints.DecimalMin; import jakarta.validation.constraints.NotNull; import java.math.BigDecimal; public record InterviewScoreReqDto( @NotNull + @DecimalMin(value = "0.0", message = "0점 이상이여야 합니다.") + @DecimalMax(value = "100.0", message = "100점 이하여야 합니다.") BigDecimal interviewScore ) { } diff --git a/src/main/java/team/themoment/hellogsmv3/domain/oneseo/service/ModifyAptitudeEvaluationScoreService.java b/src/main/java/team/themoment/hellogsmv3/domain/oneseo/service/ModifyAptitudeEvaluationScoreService.java index dbc09239..4d88582b 100644 --- a/src/main/java/team/themoment/hellogsmv3/domain/oneseo/service/ModifyAptitudeEvaluationScoreService.java +++ b/src/main/java/team/themoment/hellogsmv3/domain/oneseo/service/ModifyAptitudeEvaluationScoreService.java @@ -1,7 +1,6 @@ package team.themoment.hellogsmv3.domain.oneseo.service; import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; import team.themoment.hellogsmv3.domain.member.entity.Member; import team.themoment.hellogsmv3.domain.member.service.MemberService; @@ -9,7 +8,6 @@ import team.themoment.hellogsmv3.domain.oneseo.entity.EntranceTestResult; import team.themoment.hellogsmv3.domain.oneseo.entity.Oneseo; import team.themoment.hellogsmv3.domain.oneseo.repository.EntranceTestResultRepository; -import team.themoment.hellogsmv3.global.exception.error.ExpectedException; import java.math.BigDecimal; @@ -29,8 +27,6 @@ public void execute(Long memberId, AptitudeEvaluationScoreReqDto aptitudeEvaluat OneseoService.isBeforeSecondTest(entranceTestResult.getSecondTestPassYn()); BigDecimal aptitudeEvaluationScore = aptitudeEvaluationScoreReqDto.aptitudeEvaluationScore(); - OneseoService.validateEvaluationScore(aptitudeEvaluationScore); - entranceTestResult.modifyAptitudeEvaluationScore(aptitudeEvaluationScore); entranceTestResultRepository.save(entranceTestResult); diff --git a/src/main/java/team/themoment/hellogsmv3/domain/oneseo/service/ModifyInterviewScoreService.java b/src/main/java/team/themoment/hellogsmv3/domain/oneseo/service/ModifyInterviewScoreService.java index 1a443a51..1f1c01df 100644 --- a/src/main/java/team/themoment/hellogsmv3/domain/oneseo/service/ModifyInterviewScoreService.java +++ b/src/main/java/team/themoment/hellogsmv3/domain/oneseo/service/ModifyInterviewScoreService.java @@ -29,9 +29,8 @@ public void execute(Long memberId, InterviewScoreReqDto reqDto) { OneseoService.isBeforeSecondTest(entranceTestResult.getSecondTestPassYn()); BigDecimal interviewScore = reqDto.interviewScore(); - OneseoService.validateEvaluationScore(interviewScore); - entranceTestResult.modifyInterviewScore(interviewScore); + entranceTestResultRepository.save(entranceTestResult); } diff --git a/src/main/java/team/themoment/hellogsmv3/domain/oneseo/service/OneseoService.java b/src/main/java/team/themoment/hellogsmv3/domain/oneseo/service/OneseoService.java index 569d262c..10c30311 100644 --- a/src/main/java/team/themoment/hellogsmv3/domain/oneseo/service/OneseoService.java +++ b/src/main/java/team/themoment/hellogsmv3/domain/oneseo/service/OneseoService.java @@ -63,14 +63,6 @@ public static void isBeforeSecondTest(YesNo yn) { } } - public static void validateEvaluationScore(BigDecimal aptitudeEvaluationScore) { - BigDecimal minValue = BigDecimal.ZERO; - BigDecimal maxValue = new BigDecimal(100); - if (aptitudeEvaluationScore.compareTo(minValue) < 0 || aptitudeEvaluationScore.compareTo(maxValue) > 0) { - throw new ExpectedException("0부터 100사이의 값만 할당할 수 있습니다.", HttpStatus.BAD_REQUEST); - } - } - public static void isValidMiddleSchoolInfo(OneseoReqDto reqDto) { if ( reqDto.graduationType().equals(CANDIDATE) && (