Skip to content

Commit

Permalink
[feat] 가격대 전체 카테고리 추가 (#242)
Browse files Browse the repository at this point in the history
* [feat] change store category sequence

* [feat] delete unnecessary code

* [feat] add PriceCategory Converter

* [refac] move webConfig and related class

* [feat] delete unnecessary log
  • Loading branch information
Parkjyun authored Jan 6, 2025
1 parent 14c225d commit d21b4a3
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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<String, PriceCategory> {

@Override
public PriceCategory convert(String source) {
if (source.toUpperCase().equals(PriceCategory.ALL.toString())) {
return null;
}
return PriceCategory.valueOf(source.toUpperCase());
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -18,4 +20,9 @@ public class WebConfig implements WebMvcConfigurer {
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
resolvers.add(userIdArgumentResolver);
}

@Override
public void addFormatters(FormatterRegistry registry) {
registry.addConverter(new PriceCategoryConverter());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d21b4a3

Please sign in to comment.