-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #106 from modu-menu/feat/update-search
테이블 변경 없이 계층 구조를 나타낼 수 있도록 FoodType 수정, 카테고리 목록 조회 API 구현
- Loading branch information
Showing
21 changed files
with
374 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,67 @@ | ||
package modu.menu.food.domain; | ||
|
||
import com.fasterxml.jackson.annotation.JsonValue; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
@AllArgsConstructor | ||
public enum FoodType { | ||
|
||
// 한식 | ||
KOREAN_FOOD("한식"), | ||
KOREAN_SEAFOOD("해물,생선"), | ||
CONGEE("죽"), | ||
JOKBAL("족발, 보쌈"), | ||
HOT_POP("찌개,전골"), | ||
MEAT("육류,고기"), | ||
SUNDAE("순대"), | ||
STREET_FOOD("분식"), | ||
NOODLE("면"), | ||
LUNCH_BOX("도시락"), | ||
KOREAN_CHICKEN("닭요리"), | ||
INTESTINE("곱창,막창"), | ||
TEPPAN_YAKI("철판요리"), | ||
KOREAN_FOOD("한식", null), | ||
KOREAN_SEAFOOD("해물,생선", KOREAN_FOOD), | ||
CONGEE("죽", KOREAN_FOOD), | ||
JOKBAL("족발, 보쌈", KOREAN_FOOD), | ||
HOT_POT("찌개,전골", KOREAN_FOOD), | ||
MEAT("육류,고기", KOREAN_FOOD), | ||
SUNDAE("순대", KOREAN_FOOD), | ||
STREET_FOOD("분식", KOREAN_FOOD), | ||
NOODLE("면", KOREAN_FOOD), | ||
LUNCH_BOX("도시락", KOREAN_FOOD), | ||
KOREAN_CHICKEN("닭요리", KOREAN_FOOD), | ||
INTESTINE("곱창,막창", KOREAN_FOOD), | ||
TEPPAN_YAKI("철판요리", KOREAN_FOOD), | ||
|
||
// 일식, 중식 | ||
JAPANESE_FOOD("일식"), | ||
CHINESE_FOOD("중식"), | ||
JAPANESE_FOOD("일식", null), | ||
CHINESE_FOOD("중식", null), | ||
|
||
// 양식 | ||
WESTERN_FOOD("양식"), | ||
HAMBURGER("햄버거"), | ||
WESTERN_SEAFOOD("해산물"), | ||
PIZZA("피자"), | ||
FRENCH_FOOD("프랑스음식"), | ||
FAST_FOOD("패스트푸드"), | ||
FAMILY_RESTAURANT("패밀리레스토랑"), | ||
CHICKEN("치킨"), | ||
ITALIAN_FOOD("이탈리안"), | ||
SPANISH_FOOD("스페인"), | ||
SALAD("샐러드"), | ||
LATIN("멕시칸,브라질"), | ||
WESTERN_FOOD("양식", null), | ||
HAMBURGER("햄버거", WESTERN_FOOD), | ||
WESTERN_SEAFOOD("해산물", WESTERN_FOOD), | ||
PIZZA("피자", WESTERN_FOOD), | ||
FRENCH_FOOD("프랑스음식", WESTERN_FOOD), | ||
FAST_FOOD("패스트푸드", WESTERN_FOOD), | ||
FAMILY_RESTAURANT("패밀리레스토랑", WESTERN_FOOD), | ||
CHICKEN("치킨", WESTERN_FOOD), | ||
ITALIAN_FOOD("이탈리안", WESTERN_FOOD), | ||
SPANISH_FOOD("스페인", WESTERN_FOOD), | ||
SALAD("샐러드", WESTERN_FOOD), | ||
LATIN("멕시칸,브라질", WESTERN_FOOD), | ||
|
||
// 기타 | ||
ASIAN_FOOD("아시아음식"), | ||
BAR("술집"), | ||
BUFFET("뷔페"), | ||
DESSERT("디저트"); | ||
ASIAN_FOOD("아시아음식", null), | ||
BAR("술집", null), | ||
BUFFET("뷔페", null), | ||
DESSERT("디저트", null); | ||
|
||
private final String title; | ||
@Getter | ||
private final FoodType parent; | ||
|
||
@JsonValue | ||
public String getTitle() { | ||
return title; | ||
} | ||
|
||
// 최상위 Enum 목록을 반환하는 메서드 | ||
public static List<FoodType> getAncestor() { | ||
return Arrays.stream(FoodType.values()) | ||
.filter(foodType -> foodType.getParent() == null) | ||
.toList(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/java/modu/menu/place/api/response/CategoryResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package modu.menu.place.api.response; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import modu.menu.place.service.dto.FoodTypeServiceResponse; | ||
import modu.menu.place.service.dto.VibeTypeServiceResponse; | ||
|
||
import java.util.List; | ||
|
||
@Schema(description = "카테고리 조회 결과 DTO") | ||
@Builder | ||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class CategoryResponse { | ||
|
||
@Schema(description = "음식점 카테고리 목록") | ||
private List<FoodTypeServiceResponse> foods; | ||
|
||
@Schema(description = "분위기 목록") | ||
private List<VibeTypeServiceResponse> vibes; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/main/java/modu/menu/place/service/dto/FoodTypeServiceResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package modu.menu.place.service.dto; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import modu.menu.food.domain.FoodType; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
@Schema(description = "음식점 카테고리 DTO") | ||
@Builder | ||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class FoodTypeServiceResponse { | ||
|
||
@Schema(description = "음식점 카테고리 key") | ||
private String key; | ||
|
||
@Schema(description = "음식점 카테고리 value") | ||
private String value; | ||
|
||
@Schema(description = "하위 카테고리 목록") | ||
private List<FoodTypeServiceResponse> children; | ||
|
||
// 최상위 카테고리부터 시작하여 FoodType의 전체 계층 구조를 반환하는 메서드 | ||
public static List<FoodTypeServiceResponse> getFoodTypeHierarchy() { | ||
return FoodType.getAncestor().stream() | ||
.map(FoodTypeServiceResponse::toFoodTypeServiceResponse) | ||
.toList(); | ||
} | ||
|
||
private static FoodTypeServiceResponse toFoodTypeServiceResponse(FoodType foodType) { | ||
return FoodTypeServiceResponse.builder() | ||
.key(foodType.name()) | ||
.value(foodType.getTitle()) | ||
.children(Arrays.stream(FoodType.values()) | ||
.filter(f -> f.getParent() == foodType) | ||
.map(FoodTypeServiceResponse::toFoodTypeServiceResponse) | ||
.toList()) | ||
.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.