diff --git a/src/main/java/org/hankki/hankkiserver/api/auth/controller/AuthController.java b/src/main/java/org/hankki/hankkiserver/api/auth/controller/AuthController.java index d499167e..e447a5d5 100644 --- a/src/main/java/org/hankki/hankkiserver/api/auth/controller/AuthController.java +++ b/src/main/java/org/hankki/hankkiserver/api/auth/controller/AuthController.java @@ -3,7 +3,7 @@ import jakarta.annotation.Nullable; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; -import org.hankki.hankkiserver.auth.UserId; +import org.hankki.hankkiserver.api.common.annotation.UserId; import org.hankki.hankkiserver.api.dto.HankkiResponse; import org.hankki.hankkiserver.common.code.CommonSuccessCode; import org.hankki.hankkiserver.api.auth.service.AuthService; diff --git a/src/main/java/org/hankki/hankkiserver/api/common/PriceCategoryConverter.java b/src/main/java/org/hankki/hankkiserver/api/common/PriceCategoryConverter.java new file mode 100644 index 00000000..e8a62ffe --- /dev/null +++ b/src/main/java/org/hankki/hankkiserver/api/common/PriceCategoryConverter.java @@ -0,0 +1,19 @@ +package org.hankki.hankkiserver.api.common; + +import lombok.extern.slf4j.Slf4j; +import org.hankki.hankkiserver.api.store.parameter.PriceCategory; +import org.springframework.core.convert.converter.Converter; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +public class PriceCategoryConverter implements Converter { + + @Override + public PriceCategory convert(String source) { + if (source.toUpperCase().equals(PriceCategory.ALL.toString())) { + return null; + } + return PriceCategory.valueOf(source.toUpperCase()); + } +} diff --git a/src/main/java/org/hankki/hankkiserver/auth/UserIdArgumentResolver.java b/src/main/java/org/hankki/hankkiserver/api/common/UserIdArgumentResolver.java similarity index 92% rename from src/main/java/org/hankki/hankkiserver/auth/UserIdArgumentResolver.java rename to src/main/java/org/hankki/hankkiserver/api/common/UserIdArgumentResolver.java index 1dd34b42..072439fc 100644 --- a/src/main/java/org/hankki/hankkiserver/auth/UserIdArgumentResolver.java +++ b/src/main/java/org/hankki/hankkiserver/api/common/UserIdArgumentResolver.java @@ -1,5 +1,6 @@ -package org.hankki.hankkiserver.auth; +package org.hankki.hankkiserver.api.common; +import org.hankki.hankkiserver.api.common.annotation.UserId; import org.springframework.core.MethodParameter; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Component; diff --git a/src/main/java/org/hankki/hankkiserver/api/advice/GlobalExceptionHandler.java b/src/main/java/org/hankki/hankkiserver/api/common/advice/GlobalExceptionHandler.java similarity index 99% rename from src/main/java/org/hankki/hankkiserver/api/advice/GlobalExceptionHandler.java rename to src/main/java/org/hankki/hankkiserver/api/common/advice/GlobalExceptionHandler.java index 1858acec..37a69a2d 100644 --- a/src/main/java/org/hankki/hankkiserver/api/advice/GlobalExceptionHandler.java +++ b/src/main/java/org/hankki/hankkiserver/api/common/advice/GlobalExceptionHandler.java @@ -1,4 +1,4 @@ -package org.hankki.hankkiserver.api.advice; +package org.hankki.hankkiserver.api.common.advice; import jakarta.validation.ConstraintViolationException; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/org/hankki/hankkiserver/api/advice/ResponseAdvice.java b/src/main/java/org/hankki/hankkiserver/api/common/advice/ResponseAdvice.java similarity index 79% rename from src/main/java/org/hankki/hankkiserver/api/advice/ResponseAdvice.java rename to src/main/java/org/hankki/hankkiserver/api/common/advice/ResponseAdvice.java index 6262d815..9b6ac995 100644 --- a/src/main/java/org/hankki/hankkiserver/api/advice/ResponseAdvice.java +++ b/src/main/java/org/hankki/hankkiserver/api/common/advice/ResponseAdvice.java @@ -1,4 +1,4 @@ -package org.hankki.hankkiserver.api.advice; +package org.hankki.hankkiserver.api.common.advice; import org.hankki.hankkiserver.api.dto.HankkiResponse; import org.springframework.core.MethodParameter; @@ -19,10 +19,8 @@ public boolean supports(MethodParameter returnType, Class converterType) { @Override public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType, Class selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) { - if (returnType.getParameterType() == HankkiResponse.class) { - HttpStatus status = HttpStatus.valueOf(((HankkiResponse) body).getCode()); - response.setStatusCode(status); - } + HttpStatus status = HttpStatus.valueOf(((HankkiResponse) body).getCode()); + response.setStatusCode(status); return body; } } diff --git a/src/main/java/org/hankki/hankkiserver/auth/UserId.java b/src/main/java/org/hankki/hankkiserver/api/common/annotation/UserId.java similarity index 82% rename from src/main/java/org/hankki/hankkiserver/auth/UserId.java rename to src/main/java/org/hankki/hankkiserver/api/common/annotation/UserId.java index cb7258d2..a0f976b5 100644 --- a/src/main/java/org/hankki/hankkiserver/auth/UserId.java +++ b/src/main/java/org/hankki/hankkiserver/api/common/annotation/UserId.java @@ -1,4 +1,4 @@ -package org.hankki.hankkiserver.auth; +package org.hankki.hankkiserver.api.common.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/src/main/java/org/hankki/hankkiserver/auth/config/WebConfig.java b/src/main/java/org/hankki/hankkiserver/api/config/WebConfig.java similarity index 61% rename from src/main/java/org/hankki/hankkiserver/auth/config/WebConfig.java rename to src/main/java/org/hankki/hankkiserver/api/config/WebConfig.java index a4b74b39..195ab8db 100644 --- a/src/main/java/org/hankki/hankkiserver/auth/config/WebConfig.java +++ b/src/main/java/org/hankki/hankkiserver/api/config/WebConfig.java @@ -1,8 +1,10 @@ -package org.hankki.hankkiserver.auth.config; +package org.hankki.hankkiserver.api.config; import lombok.RequiredArgsConstructor; -import org.hankki.hankkiserver.auth.UserIdArgumentResolver; +import org.hankki.hankkiserver.api.common.PriceCategoryConverter; +import org.hankki.hankkiserver.api.common.UserIdArgumentResolver; import org.springframework.context.annotation.Configuration; +import org.springframework.format.FormatterRegistry; import org.springframework.web.method.support.HandlerMethodArgumentResolver; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @@ -18,4 +20,9 @@ public class WebConfig implements WebMvcConfigurer { public void addArgumentResolvers(List resolvers) { resolvers.add(userIdArgumentResolver); } + + @Override + public void addFormatters(FormatterRegistry registry) { + registry.addConverter(new PriceCategoryConverter()); + } } diff --git a/src/main/java/org/hankki/hankkiserver/api/favorite/controller/FavoriteController.java b/src/main/java/org/hankki/hankkiserver/api/favorite/controller/FavoriteController.java index 7080c402..5214f4ed 100644 --- a/src/main/java/org/hankki/hankkiserver/api/favorite/controller/FavoriteController.java +++ b/src/main/java/org/hankki/hankkiserver/api/favorite/controller/FavoriteController.java @@ -14,7 +14,7 @@ import org.hankki.hankkiserver.api.favorite.service.response.FavoriteOwnershipGetResponse; import org.hankki.hankkiserver.api.favorite.service.response.FavoriteSharedGetResponse; import org.hankki.hankkiserver.api.favorite.service.response.FavoritesWithStatusGetResponse; -import org.hankki.hankkiserver.auth.UserId; +import org.hankki.hankkiserver.api.common.annotation.UserId; import org.hankki.hankkiserver.common.code.CommonSuccessCode; import org.springframework.web.bind.annotation.*; diff --git a/src/main/java/org/hankki/hankkiserver/api/menu/controller/MenuController.java b/src/main/java/org/hankki/hankkiserver/api/menu/controller/MenuController.java index 589a2092..515d2d63 100644 --- a/src/main/java/org/hankki/hankkiserver/api/menu/controller/MenuController.java +++ b/src/main/java/org/hankki/hankkiserver/api/menu/controller/MenuController.java @@ -13,7 +13,7 @@ import org.hankki.hankkiserver.api.menu.service.response.MenusGetResponse; import org.hankki.hankkiserver.api.menu.service.response.MenusPostResponse; import org.hankki.hankkiserver.api.store.controller.request.MenuPostRequest; -import org.hankki.hankkiserver.auth.UserId; +import org.hankki.hankkiserver.api.common.annotation.UserId; import org.hankki.hankkiserver.common.code.CommonSuccessCode; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; diff --git a/src/main/java/org/hankki/hankkiserver/api/store/controller/StoreController.java b/src/main/java/org/hankki/hankkiserver/api/store/controller/StoreController.java index 44777968..ea424ff3 100644 --- a/src/main/java/org/hankki/hankkiserver/api/store/controller/StoreController.java +++ b/src/main/java/org/hankki/hankkiserver/api/store/controller/StoreController.java @@ -12,7 +12,7 @@ import org.hankki.hankkiserver.api.store.service.StoreQueryService; import org.hankki.hankkiserver.api.store.service.command.*; import org.hankki.hankkiserver.api.store.service.response.*; -import org.hankki.hankkiserver.auth.UserId; +import org.hankki.hankkiserver.api.common.annotation.UserId; import org.hankki.hankkiserver.common.code.CommonSuccessCode; import org.hankki.hankkiserver.domain.store.model.StoreCategory; import org.springframework.web.bind.annotation.*; diff --git a/src/main/java/org/hankki/hankkiserver/api/store/parameter/PriceCategory.java b/src/main/java/org/hankki/hankkiserver/api/store/parameter/PriceCategory.java index f809c506..c63eef94 100644 --- a/src/main/java/org/hankki/hankkiserver/api/store/parameter/PriceCategory.java +++ b/src/main/java/org/hankki/hankkiserver/api/store/parameter/PriceCategory.java @@ -7,10 +7,12 @@ @RequiredArgsConstructor public enum PriceCategory { + ALL("전체", 0, 0), K6("6000원 이하", 6000, 0), K8("6000~8000원", 8000, 6000); private final String name; private final int maxPrice; private final int minPrice; + } diff --git a/src/main/java/org/hankki/hankkiserver/api/universitystore/controller/UniversityStoreController.java b/src/main/java/org/hankki/hankkiserver/api/universitystore/controller/UniversityStoreController.java index 0daa93a6..eded7a0a 100644 --- a/src/main/java/org/hankki/hankkiserver/api/universitystore/controller/UniversityStoreController.java +++ b/src/main/java/org/hankki/hankkiserver/api/universitystore/controller/UniversityStoreController.java @@ -5,7 +5,7 @@ import org.hankki.hankkiserver.api.universitystore.controller.request.UniviersityStoreCreateRequest; import org.hankki.hankkiserver.api.universitystore.service.UniversityStoreCommandService; import org.hankki.hankkiserver.api.universitystore.service.command.UniversityStorePostCommand; -import org.hankki.hankkiserver.auth.UserId; +import org.hankki.hankkiserver.api.common.annotation.UserId; import org.hankki.hankkiserver.common.code.CommonSuccessCode; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; diff --git a/src/main/java/org/hankki/hankkiserver/api/user/controller/UserController.java b/src/main/java/org/hankki/hankkiserver/api/user/controller/UserController.java index 382882f3..d43ca3a8 100644 --- a/src/main/java/org/hankki/hankkiserver/api/user/controller/UserController.java +++ b/src/main/java/org/hankki/hankkiserver/api/user/controller/UserController.java @@ -12,7 +12,7 @@ import org.hankki.hankkiserver.api.user.service.response.UserNicknameResponse; import org.hankki.hankkiserver.api.user.service.response.UserStoresReportedGetResponse; import org.hankki.hankkiserver.api.user.service.response.UserUniversityFindResponse; -import org.hankki.hankkiserver.auth.UserId; +import org.hankki.hankkiserver.api.common.annotation.UserId; import org.hankki.hankkiserver.common.code.CommonSuccessCode; import org.springframework.web.bind.annotation.*; diff --git a/src/main/java/org/hankki/hankkiserver/domain/store/model/StoreCategory.java b/src/main/java/org/hankki/hankkiserver/domain/store/model/StoreCategory.java index accfbf2a..18dad24e 100644 --- a/src/main/java/org/hankki/hankkiserver/domain/store/model/StoreCategory.java +++ b/src/main/java/org/hankki/hankkiserver/domain/store/model/StoreCategory.java @@ -7,16 +7,16 @@ @RequiredArgsConstructor public enum StoreCategory { + ALL("전체"), KOREAN("한식"), - CHINESE("중식"), JAPANESE("일식"), + CHINESE("중식"), WESTERN("양식"), - CONVENIENCEFOOD("간편식"), + FASTFOOD("패스트푸드"), BUNSIK("분식"), + CONVENIENCEFOOD("간편식"), SALADSANDWICH("샐러드"), - FASTFOOD("패스트푸드"), - WORLD("세계음식"), - ALL("전체"); + WORLD("세계음식"); private final String name; private String url;