From dfea5da3547fdbe057e4e81dda5405271b0a2f9a Mon Sep 17 00:00:00 2001 From: ChaHyeonMin Date: Sat, 20 Jan 2024 22:44:52 +0900 Subject: [PATCH 01/13] =?UTF-8?q?fix:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=EC=97=90=EC=84=9C=20=EB=8B=A8=EA=B5=AD?= =?UTF-8?q?=EB=8C=80=20=EC=9D=B8=EC=A6=9D=20=ED=99=95=EC=9D=B8=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/dku/council/domain/user/service/UserService.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/com/dku/council/domain/user/service/UserService.java b/src/main/java/com/dku/council/domain/user/service/UserService.java index 51caadb0..f27ddcc2 100644 --- a/src/main/java/com/dku/council/domain/user/service/UserService.java +++ b/src/main/java/com/dku/council/domain/user/service/UserService.java @@ -43,10 +43,6 @@ public ResponseLoginDto login(RequestLoginDto dto) { User user = userRepository.findByStudentId(dto.getStudentId()) .orElseThrow(UserNotFoundException::new); - if (!user.isDkuChecked()) { - throw new DkuAuthNotRefreshedException(); - } - if (passwordEncoder.matches(dto.getPassword(), user.getPassword()) && user.isDkuChecked()) { AuthenticationToken token = jwtProvider.issue(user); userInfoService.cacheUserInfo(user.getId(), user); From 141013b4a8b483d344139fa7a2f6c72857832c6d Mon Sep 17 00:00:00 2001 From: ChaHyeonMin Date: Sun, 21 Jan 2024 00:23:22 +0900 Subject: [PATCH 02/13] =?UTF-8?q?feat:=20=EB=8B=A8=EA=B5=AD=EB=8C=80=20?= =?UTF-8?q?=EC=9E=AC=ED=95=99=EC=83=9D=20=EC=9D=B8=EC=A6=9D=20=EC=8B=9C=20?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=97=85=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8=ED=95=98=EB=8A=94=20=EB=B9=84=EC=A6=88=EB=8B=88?= =?UTF-8?q?=EC=8A=A4=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dku/council/domain/user/model/entity/User.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/com/dku/council/domain/user/model/entity/User.java b/src/main/java/com/dku/council/domain/user/model/entity/User.java index 28f4c13e..5f7b35ea 100644 --- a/src/main/java/com/dku/council/domain/user/model/entity/User.java +++ b/src/main/java/com/dku/council/domain/user/model/entity/User.java @@ -204,6 +204,17 @@ public void changeIsDkuChecked() { this.isDkuChecked = !this.isDkuChecked; } + /** + * 단국대 학생 정보를 업데이트합니다. + * + * @param age 나이 + * @param gender 성별 + */ + public void updateDkuInfo(String age, String gender) { + this.isDkuChecked = true; + this.age = age; + this.gender = gender; + } /** * 매년 1월 1일 사용자들의 나이 1을 증가시킵니다. From cac99e3a98512aef2b6a367e325717141ca67dc0 Mon Sep 17 00:00:00 2001 From: ChaHyeonMin Date: Sun, 21 Jan 2024 00:23:42 +0900 Subject: [PATCH 03/13] =?UTF-8?q?remove:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=EC=8B=9C=20isDkuChecked=20=ED=99=95=EC=9D=B8=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/dku/council/domain/user/service/UserService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/dku/council/domain/user/service/UserService.java b/src/main/java/com/dku/council/domain/user/service/UserService.java index f27ddcc2..86c98b54 100644 --- a/src/main/java/com/dku/council/domain/user/service/UserService.java +++ b/src/main/java/com/dku/council/domain/user/service/UserService.java @@ -43,7 +43,7 @@ public ResponseLoginDto login(RequestLoginDto dto) { User user = userRepository.findByStudentId(dto.getStudentId()) .orElseThrow(UserNotFoundException::new); - if (passwordEncoder.matches(dto.getPassword(), user.getPassword()) && user.isDkuChecked()) { + if (passwordEncoder.matches(dto.getPassword(), user.getPassword())) { AuthenticationToken token = jwtProvider.issue(user); userInfoService.cacheUserInfo(user.getId(), user); return new ResponseLoginDto(token); From 8f46fee15d9952cc14aad8afabd8bbe840660238 Mon Sep 17 00:00:00 2001 From: ChaHyeonMin Date: Sun, 21 Jan 2024 00:24:19 +0900 Subject: [PATCH 04/13] =?UTF-8?q?feat:=20CustomHttpStatus=20Enum=20?= =?UTF-8?q?=ED=81=B4=EB=9E=98=EC=8A=A4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/error/CustomHttpStatus.java | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 src/main/java/com/dku/council/global/error/CustomHttpStatus.java diff --git a/src/main/java/com/dku/council/global/error/CustomHttpStatus.java b/src/main/java/com/dku/council/global/error/CustomHttpStatus.java new file mode 100644 index 00000000..3efa6414 --- /dev/null +++ b/src/main/java/com/dku/council/global/error/CustomHttpStatus.java @@ -0,0 +1,99 @@ +package com.dku.council.global.error; + +import lombok.Getter; +import org.springframework.lang.Nullable; + +public enum CustomHttpStatus{ + + /** + * 600 : 단국대학교 학생 인증이 없을 경우 + */ + REQUIRED_DKU_UPDATE(600, CustomSeries.DKU_ERROR, "Required DkuInfo"); + + private static final CustomHttpStatus[] VALUES; + + static { + VALUES = values(); + } + + private final int value; + + private final CustomSeries series; + + @Getter + private final String reasonPhrase; + + CustomHttpStatus(int value, CustomSeries series, String reasonPhrase) { + this.value = value; + this.series = series; + this.reasonPhrase = reasonPhrase; + } + + public int value() { + return this.value; + } + + public CustomSeries series() { + return this.series; + } + + public String toString() { + return this.value + " " + name(); + } + + public static CustomHttpStatus valueOf(int statusCode) { + CustomHttpStatus status = resolve(statusCode); + if (status == null) { + throw new IllegalArgumentException("No matching constant for [" + statusCode + "]"); + } + return status; + } + + @Nullable + public static CustomHttpStatus resolve(int statusCode) { + for (CustomHttpStatus status : VALUES) { + if (status.value == statusCode) { + return status; + } + } + return null; + } + + public enum CustomSeries { + DKU_ERROR(6); + + private final int value; + + CustomSeries(int value) { + this.value = value; + } + + public int value() { + return this.value; + } + + @Deprecated + public static CustomSeries valueOf(CustomHttpStatus status) { + return status.series; + } + + public static CustomSeries valueOf(int statusCode) { + CustomSeries series = resolve(statusCode); + if (series == null) { + throw new IllegalArgumentException("No matching constant for [" + statusCode + "]"); + } + return series; + } + + @Nullable + public static CustomSeries resolve(int statusCode) { + int seriesCode = statusCode / 100; + for (CustomSeries series : values()) { + if (series.value == seriesCode) { + return series; + } + } + return null; + } + } +} From 5251e83235d2b4c3e39db29bfafd84bacde50a91 Mon Sep 17 00:00:00 2001 From: ChaHyeonMin Date: Sun, 21 Jan 2024 00:24:40 +0900 Subject: [PATCH 05/13] =?UTF-8?q?fix:=20=EC=97=90=EB=9F=AC=20Response=20dt?= =?UTF-8?q?o=EC=97=90=20=EC=83=81=ED=83=9C=20=EC=BD=94=EB=93=9C=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 --- .../java/com/dku/council/global/error/ErrorResponseDto.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/dku/council/global/error/ErrorResponseDto.java b/src/main/java/com/dku/council/global/error/ErrorResponseDto.java index 056410ac..607fdb0c 100644 --- a/src/main/java/com/dku/council/global/error/ErrorResponseDto.java +++ b/src/main/java/com/dku/council/global/error/ErrorResponseDto.java @@ -14,7 +14,8 @@ public class ErrorResponseDto { private final String timestamp; private final String trackingId; - private final HttpStatus status; + private final int statusCode; + private final String status; private final String code; private final List message; @@ -22,6 +23,7 @@ public class ErrorResponseDto { public ErrorResponseDto(MessageSource messageSource, Locale locale, LocalizedMessageException e) { this.timestamp = LocalDateTime.now().toString(); this.trackingId = UUID.randomUUID().toString(); + this.statusCode = e.getStatusCode(); this.status = e.getStatus(); this.code = e.getCode(); this.message = e.getMessages(messageSource, locale); From 071b736d41056401a456c632d36a982b44c87ea2 Mon Sep 17 00:00:00 2001 From: ChaHyeonMin Date: Sun, 21 Jan 2024 00:25:02 +0900 Subject: [PATCH 06/13] =?UTF-8?q?fix:=20LocalizedMessageException=EC=97=90?= =?UTF-8?q?=20=EC=83=81=ED=83=9C=20=EC=BD=94=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/LocalizedMessageException.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/dku/council/global/error/exception/LocalizedMessageException.java b/src/main/java/com/dku/council/global/error/exception/LocalizedMessageException.java index aa533f47..d8b84d75 100644 --- a/src/main/java/com/dku/council/global/error/exception/LocalizedMessageException.java +++ b/src/main/java/com/dku/council/global/error/exception/LocalizedMessageException.java @@ -1,5 +1,6 @@ package com.dku.council.global.error.exception; +import com.dku.council.global.error.CustomHttpStatus; import lombok.Getter; import org.springframework.context.MessageSource; import org.springframework.http.HttpStatus; @@ -11,21 +12,32 @@ @Getter public class LocalizedMessageException extends RuntimeException { - private final HttpStatus status; + private final int code; + private final String status; private final String messageId; private final Object[] arguments; private String customMessage = null; public LocalizedMessageException(HttpStatus status, String messageId, Object... arguments) { super(formatMessage(messageId, arguments)); - this.status = status; + this.code = status.value(); + this.status = status.name(); this.messageId = messageId; this.arguments = arguments; } public LocalizedMessageException(Throwable cause, HttpStatus status, String messageId, Object... arguments) { super(formatMessage(messageId, arguments), cause); - this.status = status; + this.code = status.value(); + this.status = status.name(); + this.messageId = messageId; + this.arguments = arguments; + } + + public LocalizedMessageException(CustomHttpStatus status, String messageId, Object... arguments) { + super(formatMessage(messageId, arguments)); + this.code = status.value(); + this.status = status.name(); this.messageId = messageId; this.arguments = arguments; } @@ -46,6 +58,10 @@ public String getCode() { return getClass().getSimpleName(); } + public int getStatusCode() { + return this.code; + } + public static LocalizedMessageException of(Exception e) { return new UnexpectedException(e); } From 011a29e2b482cfb25f256f921a6221ab9a598a95 Mon Sep 17 00:00:00 2001 From: ChaHyeonMin Date: Sun, 21 Jan 2024 00:25:21 +0900 Subject: [PATCH 07/13] =?UTF-8?q?fix:=20=EC=97=90=EB=9F=AC=20=EC=9D=91?= =?UTF-8?q?=EB=8B=B5=20=EC=8B=9C=20=EC=83=81=ED=83=9C=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/dku/council/global/error/ExceptionHandlerFilter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/dku/council/global/error/ExceptionHandlerFilter.java b/src/main/java/com/dku/council/global/error/ExceptionHandlerFilter.java index 144c64d6..93f36db0 100644 --- a/src/main/java/com/dku/council/global/error/ExceptionHandlerFilter.java +++ b/src/main/java/com/dku/council/global/error/ExceptionHandlerFilter.java @@ -38,7 +38,7 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse private void writeErrorResponse(HttpServletResponse response, Locale locale, LocalizedMessageException ex) throws IOException { ErrorResponseDto dto = new ErrorResponseDto(messageSource, locale, ex); log.error("A problem has occurred in filter: [id={}]", dto.getTrackingId(), ex); - writeResponse(response, dto, ex.getStatus().value()); + writeResponse(response, dto, Integer.parseInt(ex.getCode())); } private void writeUnexpectedErrorResponse(HttpServletResponse response, Locale locale, Exception ex) throws IOException { From e5d7aa6280c96b6b1b44c015e1503c2d83fc5a62 Mon Sep 17 00:00:00 2001 From: ChaHyeonMin Date: Sun, 21 Jan 2024 00:25:41 +0900 Subject: [PATCH 08/13] =?UTF-8?q?fix:=20=EB=8B=A8=EA=B5=AD=EB=8C=80=20?= =?UTF-8?q?=EC=9E=AC=ED=95=99=EC=83=9D=20=EC=9D=B8=EC=A6=9D=20=EC=8B=9C=20?= =?UTF-8?q?=EC=84=B1=EB=B3=84,=20=EB=82=98=EC=9D=B4=20=EB=B0=8F=20isDkuChe?= =?UTF-8?q?cked=20=EC=83=81=ED=83=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/dku/council/infra/dku/service/DkuAuthBatchService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/dku/council/infra/dku/service/DkuAuthBatchService.java b/src/main/java/com/dku/council/infra/dku/service/DkuAuthBatchService.java index 16327ea8..082a2d51 100644 --- a/src/main/java/com/dku/council/infra/dku/service/DkuAuthBatchService.java +++ b/src/main/java/com/dku/council/infra/dku/service/DkuAuthBatchService.java @@ -46,7 +46,7 @@ public void changeDkuAuth(RequestDkuStudentDto dto) { if (info.getStudentState().equals("재학")) { User user = userRepository.findByStudentId(dto.getDkuStudentId()) .orElseThrow(UserNotFoundException::new); - user.changeIsDkuChecked(); + user.updateDkuInfo(info.getAge(), info.getGender()); } else { throw new FailedAuthRefreshException(); From c9531579fa0cc72877890f9739a0eea0399e7352 Mon Sep 17 00:00:00 2001 From: ChaHyeonMin Date: Sun, 21 Jan 2024 00:26:06 +0900 Subject: [PATCH 09/13] =?UTF-8?q?fix:=20HttpStatus=EC=9D=B8=EC=A7=80=20Cus?= =?UTF-8?q?tomHttpStatus=EC=9D=B8=EC=A7=80=EB=A5=BC=20=EB=B9=84=EA=B5=90?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EB=A9=94=EC=86=8C=EB=93=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dku/council/global/error/ControllerAdvisor.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/dku/council/global/error/ControllerAdvisor.java b/src/main/java/com/dku/council/global/error/ControllerAdvisor.java index 523584aa..9c287a51 100644 --- a/src/main/java/com/dku/council/global/error/ControllerAdvisor.java +++ b/src/main/java/com/dku/council/global/error/ControllerAdvisor.java @@ -8,6 +8,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.context.MessageSource; import org.springframework.dao.DataIntegrityViolationException; +import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.http.converter.HttpMessageNotReadableException; import org.springframework.security.access.AccessDeniedException; @@ -35,7 +36,15 @@ public class ControllerAdvisor { protected ResponseEntity localizedException(LocalizedMessageException e, Locale locale) { ErrorResponseDto dto = new ErrorResponseDto(messageSource, locale, e); log.error("A problem has occurred in controller advice: [id={}]", dto.getTrackingId(), e); - return filter(e, ResponseEntity.status(e.getStatus()).body(dto)); + return filter(e, ResponseEntity.status(findHttpStatus(e.getStatus())).body(dto)); + } + + private int findHttpStatus(String status) { + if (CustomHttpStatus.valueOf(status) != null) { + return CustomHttpStatus.valueOf(status).value(); + } else { + return HttpStatus.valueOf(status).value(); + } } @ExceptionHandler From aa8c96e8540bc2ba59783119289076693328987a Mon Sep 17 00:00:00 2001 From: ChaHyeonMin Date: Sun, 21 Jan 2024 00:26:25 +0900 Subject: [PATCH 10/13] =?UTF-8?q?fix:=20=EB=8B=A8=EA=B5=AD=EB=8C=80?= =?UTF-8?q?=ED=95=99=EA=B5=90=20=EC=9E=AC=ED=95=99=EC=83=9D=20=EC=9D=B8?= =?UTF-8?q?=EC=A6=9D=20=EC=98=A4=EB=A5=98=20=EC=8B=9C=20HttpStatus?= =?UTF-8?q?=EB=A5=BC=20=EC=BB=A4=EC=8A=A4=ED=85=80=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/user/exception/RequiredDkuUpdateException.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/dku/council/domain/user/exception/RequiredDkuUpdateException.java b/src/main/java/com/dku/council/domain/user/exception/RequiredDkuUpdateException.java index 16792770..cebee527 100644 --- a/src/main/java/com/dku/council/domain/user/exception/RequiredDkuUpdateException.java +++ b/src/main/java/com/dku/council/domain/user/exception/RequiredDkuUpdateException.java @@ -1,11 +1,12 @@ package com.dku.council.domain.user.exception; +import com.dku.council.global.error.CustomHttpStatus; import com.dku.council.global.error.exception.LocalizedMessageException; import org.springframework.http.HttpStatus; public class RequiredDkuUpdateException extends LocalizedMessageException { public RequiredDkuUpdateException() { - super(HttpStatus.NOT_ACCEPTABLE, "required.dku-update"); + super(CustomHttpStatus.REQUIRED_DKU_UPDATE, "required.dku-update"); } } From c09783cc93a3fda1013ef7633f447c0f0c31ba59 Mon Sep 17 00:00:00 2001 From: ChaHyeonMin Date: Sun, 21 Jan 2024 01:00:17 +0900 Subject: [PATCH 11/13] =?UTF-8?q?fix:=20enum=20=EA=B0=92=EC=9D=84=20?= =?UTF-8?q?=EB=8B=A4=EB=A5=B8=20=ED=81=B4=EB=9E=98=EC=8A=A4=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=B0=B8=EC=A1=B0=ED=95=98=EA=B8=B0=20=EC=9C=84?= =?UTF-8?q?=ED=95=B4=EC=84=9C=20public=EC=9C=BC=EB=A1=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/dku/council/global/error/CustomHttpStatus.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/dku/council/global/error/CustomHttpStatus.java b/src/main/java/com/dku/council/global/error/CustomHttpStatus.java index 3efa6414..81e03d6a 100644 --- a/src/main/java/com/dku/council/global/error/CustomHttpStatus.java +++ b/src/main/java/com/dku/council/global/error/CustomHttpStatus.java @@ -10,7 +10,7 @@ public enum CustomHttpStatus{ */ REQUIRED_DKU_UPDATE(600, CustomSeries.DKU_ERROR, "Required DkuInfo"); - private static final CustomHttpStatus[] VALUES; + public static final CustomHttpStatus[] VALUES; static { VALUES = values(); From 81aaf5d924f860e914546307c752999d95b19cc6 Mon Sep 17 00:00:00 2001 From: ChaHyeonMin Date: Sun, 21 Jan 2024 01:00:41 +0900 Subject: [PATCH 12/13] =?UTF-8?q?fix:=20CustomHttpStatus=20=EC=95=88?= =?UTF-8?q?=EC=97=90=20name=EC=9D=B4=20=EC=9E=88=EC=9D=84=20=EA=B2=BD?= =?UTF-8?q?=EC=9A=B0=20CustomHttpStatus=EB=A1=9C=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=EC=B6=9C=EB=A0=A5=ED=95=98=EB=8A=94=20=EB=A1=9C=EC=A7=81=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 --- .../council/global/error/ControllerAdvisor.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/dku/council/global/error/ControllerAdvisor.java b/src/main/java/com/dku/council/global/error/ControllerAdvisor.java index 9c287a51..878b1145 100644 --- a/src/main/java/com/dku/council/global/error/ControllerAdvisor.java +++ b/src/main/java/com/dku/council/global/error/ControllerAdvisor.java @@ -36,15 +36,19 @@ public class ControllerAdvisor { protected ResponseEntity localizedException(LocalizedMessageException e, Locale locale) { ErrorResponseDto dto = new ErrorResponseDto(messageSource, locale, e); log.error("A problem has occurred in controller advice: [id={}]", dto.getTrackingId(), e); - return filter(e, ResponseEntity.status(findHttpStatus(e.getStatus())).body(dto)); + if (containsEnum(e.getStatus())) { + return filter(e, ResponseEntity.status(e.getStatusCode()).body(dto)); + } + return filter(e, ResponseEntity.status(HttpStatus.valueOf(e.getStatus())).body(dto)); } - private int findHttpStatus(String status) { - if (CustomHttpStatus.valueOf(status) != null) { - return CustomHttpStatus.valueOf(status).value(); - } else { - return HttpStatus.valueOf(status).value(); + private boolean containsEnum(String constantName) { + for (CustomHttpStatus status : CustomHttpStatus.VALUES) { + if (status.name().equals(constantName)) { + return true; + } } + return false; } @ExceptionHandler From 73ad9e5a8d9811b60c7d0b3bc9d3932510c9044a Mon Sep 17 00:00:00 2001 From: ChaHyeonMin Date: Sun, 21 Jan 2024 01:04:25 +0900 Subject: [PATCH 13/13] =?UTF-8?q?fix:=20ErrorResponseDto=20=EA=B8=B0?= =?UTF-8?q?=EB=8C=80=EA=B0=92=20=EC=BD=94=EB=93=9C=EC=97=90=20=EB=A7=9E?= =?UTF-8?q?=EA=B2=8C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/dku/council/global/error/ErrorResponseDtoTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/dku/council/global/error/ErrorResponseDtoTest.java b/src/test/java/com/dku/council/global/error/ErrorResponseDtoTest.java index 927ad6e1..627f69c1 100644 --- a/src/test/java/com/dku/council/global/error/ErrorResponseDtoTest.java +++ b/src/test/java/com/dku/council/global/error/ErrorResponseDtoTest.java @@ -38,6 +38,6 @@ public void create_properly_localized() { DateTimeFormatter.ISO_DATE_TIME.parse(dto.getTimestamp()); assertThat(dto.getCode()).isEqualTo("LocalizedMessageException"); assertThat(dto.getMessage()).isEqualTo(List.of("localizedMessage")); - assertThat(dto.getStatus()).isEqualTo(HttpStatus.OK); + assertThat(dto.getStatus()).isEqualTo(HttpStatus.OK.name()); } } \ No newline at end of file