From c4bcfd615cee5fa0864a9dafc281f8724863b909 Mon Sep 17 00:00:00 2001 From: david-parkk Date: Mon, 19 Aug 2024 23:01:51 +0900 Subject: [PATCH 1/4] fix: init.sql --- mysql/init/init.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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, From 9ec258451cb835c1e9a4a398e2dccfad9373f6f6 Mon Sep 17 00:00:00 2001 From: david-parkk Date: Mon, 19 Aug 2024 23:25:06 +0900 Subject: [PATCH 2/4] feat: isUserOwned --- .../onboarding/api/OnBoardingController.java | 10 +++++++--- .../api/response/GetQuestionRecommands.java | 13 +++++++++++-- .../onboarding/api/response/GetRecommend.java | 4 +++- .../api/response/GetTagRecommends.java | 16 ++++++++++++---- 4 files changed, 33 insertions(+), 10 deletions(-) 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<>(); // 가변 리스트로 초기화 } From 05806abec2706c608f4645d49c92fdd374baf27a Mon Sep 17 00:00:00 2001 From: david-parkk Date: Tue, 20 Aug 2024 00:34:00 +0900 Subject: [PATCH 3/4] feat: menuIdentifier --- .../backend/domain/menu/dto/MenuIdentifier.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/main/java/com/ourMenu/backend/domain/menu/dto/MenuIdentifier.java 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; +} From 06e1527a699573214883af56166295874fe9b557 Mon Sep 17 00:00:00 2001 From: david-parkk Date: Tue, 20 Aug 2024 02:11:32 +0900 Subject: [PATCH 4/4] fix: defaultTag --- .../ourMenu/backend/domain/onboarding/domain/DefaultTag.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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("단체", "단체로 방문한다면,");