From 40a8edceed89c91195ac5a84073e656d974e3704 Mon Sep 17 00:00:00 2001 From: JinSeoHyun <15roa1121@gmail.com> Date: Wed, 6 Nov 2024 18:46:56 +0900 Subject: [PATCH] =?UTF-8?q?10=EC=A3=BC=EC=B0=A8=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../boomerang/global/config/RedisConfig.java | 2 ++ .../boomerang/global/config/WebConfig.java | 4 ++-- .../global/utils/MainStepEnumConverter.java | 3 +-- .../progress/domain/MainStepEnum.java | 18 ++++++++--------- .../progress/domain/SubStepEnum.java | 20 ++++++++++--------- 5 files changed, 25 insertions(+), 22 deletions(-) diff --git a/boomerang/src/main/java/boomerang/global/config/RedisConfig.java b/boomerang/src/main/java/boomerang/global/config/RedisConfig.java index a8d00e02..5e67814f 100644 --- a/boomerang/src/main/java/boomerang/global/config/RedisConfig.java +++ b/boomerang/src/main/java/boomerang/global/config/RedisConfig.java @@ -3,6 +3,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.connection.RedisStandaloneConfiguration; import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; @@ -31,6 +32,7 @@ public RedisConnectionFactory redisConnectionFactory() { return new LettuceConnectionFactory(redisConfig); } + @Primary @Bean public RedisTemplate redisTemplate() { RedisTemplate redisTemplate = new RedisTemplate<>(); diff --git a/boomerang/src/main/java/boomerang/global/config/WebConfig.java b/boomerang/src/main/java/boomerang/global/config/WebConfig.java index ff6585b6..4b08f0bc 100644 --- a/boomerang/src/main/java/boomerang/global/config/WebConfig.java +++ b/boomerang/src/main/java/boomerang/global/config/WebConfig.java @@ -12,8 +12,8 @@ public class WebConfig implements WebMvcConfigurer { @Override public void addFormatters(FormatterRegistry registry) { -// registry.addConverter(new MainStepEnumConverter()); -// registry.addConverter(new SubStepEnumC onverter()); + registry.addConverter(new MainStepEnumConverter()); + registry.addConverter(new SubStepEnumConverter()); } @Override diff --git a/boomerang/src/main/java/boomerang/global/utils/MainStepEnumConverter.java b/boomerang/src/main/java/boomerang/global/utils/MainStepEnumConverter.java index 19a035a9..be36701f 100644 --- a/boomerang/src/main/java/boomerang/global/utils/MainStepEnumConverter.java +++ b/boomerang/src/main/java/boomerang/global/utils/MainStepEnumConverter.java @@ -8,7 +8,6 @@ public class MainStepEnumConverter implements Converter { @Override public MainStepEnum convert(String value) { -// return MainStepEnum.fromStepName(value); - return null; + return MainStepEnum.fromStepName(value); } } diff --git a/boomerang/src/main/java/boomerang/progress/domain/MainStepEnum.java b/boomerang/src/main/java/boomerang/progress/domain/MainStepEnum.java index e56df36e..51537643 100644 --- a/boomerang/src/main/java/boomerang/progress/domain/MainStepEnum.java +++ b/boomerang/src/main/java/boomerang/progress/domain/MainStepEnum.java @@ -30,15 +30,15 @@ public enum MainStepEnum { this.subStepEnumList = subStepEnumList; } -// @JsonCreator -// public static MainStepEnum fromStepName(String stepName) { -// for (MainStepEnum mainStepEnum : MainStepEnum.values()) { -// if (mainStepEnum.mainStepName.equals(stepName)) { -// return mainStepEnum; -// } -// } -// throw new IllegalArgumentException(ErrorCode.PROGRESS_MAIN_INVALID_NAME.getMessage()); -// } + @JsonCreator + public static MainStepEnum fromStepName(String stepName) { + for (MainStepEnum mainStepEnum : MainStepEnum.values()) { + if (mainStepEnum.mainStepName.equals(stepName)) { + return mainStepEnum; + } + } + throw new IllegalArgumentException(ErrorCode.PROGRESS_MAIN_INVALID_NAME.getMessage()); + } @JsonValue public String getMainStepName() { diff --git a/boomerang/src/main/java/boomerang/progress/domain/SubStepEnum.java b/boomerang/src/main/java/boomerang/progress/domain/SubStepEnum.java index fda68c0b..203e12c1 100644 --- a/boomerang/src/main/java/boomerang/progress/domain/SubStepEnum.java +++ b/boomerang/src/main/java/boomerang/progress/domain/SubStepEnum.java @@ -1,5 +1,7 @@ package boomerang.progress.domain; +import boomerang.global.response.ErrorCode; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; public enum SubStepEnum { @@ -14,15 +16,15 @@ public enum SubStepEnum { this.content = content; } -// @JsonCreator -// public static SubStepEnum fromStepName(String stepName) { -// for (SubStepEnum subStepEnum : SubStepEnum.values()) { -// if (subStepEnum.subStepName.equals(stepName)) { -// return subStepEnum; -// } -// } -// throw new IllegalStateException(ErrorCode.PROGRESS_SUB_INVALID_NAME.getMessage()); -// } + @JsonCreator + public static SubStepEnum fromStepName(String stepName) { + for (SubStepEnum subStepEnum : SubStepEnum.values()) { + if (subStepEnum.subStepName.equals(stepName)) { + return subStepEnum; + } + } + throw new IllegalStateException(ErrorCode.PROGRESS_SUB_INVALID_NAME.getMessage()); + } @JsonValue public String getSubStepName() {