diff --git a/mysql/init/init.sql b/mysql/init/init.sql index f87f043..14be10a 100644 --- a/mysql/init/init.sql +++ b/mysql/init/init.sql @@ -1,4 +1,4 @@ -use users_db +use users_db; create table article ( menu_count integer not null, diff --git a/src/main/java/com/ourMenu/backend/domain/menu/dto/MenuIdentifier.java b/src/main/java/com/ourMenu/backend/domain/menu/dto/MenuIdentifier.java new file mode 100644 index 0000000..bc247e5 --- /dev/null +++ b/src/main/java/com/ourMenu/backend/domain/menu/dto/MenuIdentifier.java @@ -0,0 +1,14 @@ +package com.ourMenu.backend.domain.menu.dto; + +import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.Getter; + +@Getter +@AllArgsConstructor +@EqualsAndHashCode +public class MenuIdentifier { + + private Long groupId; + private Long userId; +} diff --git a/src/main/java/com/ourMenu/backend/domain/onboarding/api/OnBoardingController.java b/src/main/java/com/ourMenu/backend/domain/onboarding/api/OnBoardingController.java index 9df314d..0fae229 100644 --- a/src/main/java/com/ourMenu/backend/domain/onboarding/api/OnBoardingController.java +++ b/src/main/java/com/ourMenu/backend/domain/onboarding/api/OnBoardingController.java @@ -22,7 +22,8 @@ import java.util.ArrayList; import java.util.List; -import java.util.Random; + +import static java.lang.Math.min; @RestController @RequiredArgsConstructor @@ -50,13 +51,16 @@ public ApiResponse getQuestionRecommend(@RequestParam(val } List menuList = new ArrayList<>(); menuList.addAll(onBoardService.saveAndFindStoreByQuestionAnswer(userId, questionId, answerType)); + int boundary = menuList.size() - 1; + menuList.addAll(onBoardService.findOtherUserMenusByQuestionAnswer(userId, questionId, answerType)); + boundary = min(boundary, 14); if (menuList.size() > 15) { menuList = menuList.subList(0, 15); } - return ApiUtils.success(GetQuestionRecommands.toDto(menuList, questionId, answerType)); + return ApiUtils.success(GetQuestionRecommands.toDto(menuList, questionId, answerType, boundary)); } @@ -67,7 +71,7 @@ public ApiResponse> getQuestionRecommend(@UserId Long use List getTagRecommendsList = new ArrayList<>(); for (DefaultTag defaultTag : defaultTagList) { List menuList1 = onBoardService.findStoreByRandomTag(userId, defaultTag); - getTagRecommendsList.add(GetTagRecommends.toDto(menuList1, defaultTag)); + getTagRecommendsList.add(GetTagRecommends.toDtoOwn(menuList1, defaultTag)); List menuList2 = onBoardService.findOtherStoreByRandomTag(userId, defaultTag); getTagRecommendsList.get(getTagRecommendsList.size()-1).addAll(menuList2); diff --git a/src/main/java/com/ourMenu/backend/domain/onboarding/api/response/GetQuestionRecommands.java b/src/main/java/com/ourMenu/backend/domain/onboarding/api/response/GetQuestionRecommands.java index be48a84..489b127 100644 --- a/src/main/java/com/ourMenu/backend/domain/onboarding/api/response/GetQuestionRecommands.java +++ b/src/main/java/com/ourMenu/backend/domain/onboarding/api/response/GetQuestionRecommands.java @@ -7,6 +7,7 @@ import lombok.Builder; import lombok.Getter; +import java.util.ArrayList; import java.util.List; @Getter @@ -17,8 +18,16 @@ public class GetQuestionRecommands { private String recommendImgUrl; private List menus; - public static GetQuestionRecommands toDto(List menus, int questionId, AnswerType answerType) { - List recommandList = menus.stream().map(GetRecommend::toDto).toList(); + public static GetQuestionRecommands toDto(List menus, int questionId, AnswerType answerType,int boundary) { + List recommandList = new ArrayList<>(); + for(int i=0 ;i menus; - public static GetTagRecommends toDto(List menuList, DefaultTag tag) { - List recommandList = menuList.stream().map(GetRecommend::toDto).toList(); + public static GetTagRecommends toDtoOwn(List menuList, DefaultTag tag) { + List recommandList = menuList.stream().map(menu->GetRecommend.toDto(menu,true)).toList(); + return GetTagRecommends.builder() + .tagName(tag.getTagMemo()) + .menus(new ArrayList<>(recommandList)) + .build(); + + } + + public static GetTagRecommends toDtoOther(List menuList, DefaultTag tag) { + List recommandList = menuList.stream().map(menu->GetRecommend.toDto(menu,false)).toList(); return GetTagRecommends.builder() .tagName(tag.getTagMemo()) .menus(new ArrayList<>(recommandList)) @@ -30,7 +38,7 @@ public static GetTagRecommends toDto(List menuList, DefaultTag tag) { } public void addAll(List menuList) { - List recommandList = menuList.stream().map(GetRecommend::toDto).toList(); + List recommandList = menuList.stream().map(menu->GetRecommend.toDto(menu,false)).toList(); if (menus == null) { menus = new ArrayList<>(); // 가변 리스트로 초기화 } diff --git a/src/main/java/com/ourMenu/backend/domain/onboarding/domain/DefaultTag.java b/src/main/java/com/ourMenu/backend/domain/onboarding/domain/DefaultTag.java index 78fce51..2047f48 100644 --- a/src/main/java/com/ourMenu/backend/domain/onboarding/domain/DefaultTag.java +++ b/src/main/java/com/ourMenu/backend/domain/onboarding/domain/DefaultTag.java @@ -28,8 +28,8 @@ public enum DefaultTag { HOT_SPICY("얼큰함", "얼큰함이 살아있는, "), SOLO("혼밥", "혼자 밥먹기 좋은 곳,"), WARM("뜨끈함", "땀나는 뜨끈함,"), - BUSINESS("비즈니스미팅", "비즈니스미팅이 있을 땐,"), - PROMISE("친구약속", "친구와 약속이 있다면?"), + BUSINESS("비즈니스 미팅", "비즈니스미팅이 있을 땐,"), + PROMISE("친구 약속", "친구와 약속이 있다면?"), DATE("데이트", "데이트 하는 날엔,"), BUY_FOOD("밥약", "밥약하기 좋은 곳,"), ORGANIZATION("단체", "단체로 방문한다면,");