From b048c2e1a0bca640cba74faba3713bef26be19a2 Mon Sep 17 00:00:00 2001 From: sanghee0820 Date: Thu, 10 Oct 2024 10:19:14 +0900 Subject: [PATCH 01/20] =?UTF-8?q?[fix]=20=EC=A3=BC=EC=86=8C=EB=A5=BC=20?= =?UTF-8?q?=ED=8C=8C=EC=8B=B1=ED=95=A0=20=EB=95=8C=20=EB=84=88=EB=AC=B4=20?= =?UTF-8?q?=EC=84=B8=EB=B6=80=20=EC=A0=95=EB=B3=B4=EB=A5=BC=20=EB=B0=98?= =?UTF-8?q?=EC=98=81=ED=95=98=EC=A7=80=20=EC=95=8A=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/team7/inplace/crawling/application/AddressUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/team7/inplace/crawling/application/AddressUtil.java b/src/main/java/team7/inplace/crawling/application/AddressUtil.java index 5ebd55cb..ad241ebd 100644 --- a/src/main/java/team7/inplace/crawling/application/AddressUtil.java +++ b/src/main/java/team7/inplace/crawling/application/AddressUtil.java @@ -9,7 +9,7 @@ @NoArgsConstructor(access = PRIVATE) public class AddressUtil { - private static final String ADDRESS_REGEX = "[가-힣0-9]+(?:도|시|구|군|읍|면|동|리|로|길)[^#,\\n()]+(?:동|읍|면|리|로|길|호|층|번지)[^#,\\n()]+"; + private static final String ADDRESS_REGEX = "[가-힣0-9]+(?:도|시|구|군|읍|면|동|리|로|길)[^#,\\n()]+(?:동|읍|면|리|로|길)[^#]?"; public static String extractAddress(JsonNode snippet) { From 644aa69c95292add6665c702f1ee3fc64bfe49b7 Mon Sep 17 00:00:00 2001 From: sanghee0820 Date: Thu, 10 Oct 2024 11:01:39 +0900 Subject: [PATCH 02/20] =?UTF-8?q?[fix]=20=EB=A9=94=EB=89=B4=20=EA=B0=80?= =?UTF-8?q?=EA=B2=A9=20=ED=8C=8C=EC=8B=B1=20=EC=95=88=EB=90=98=EB=8A=94=20?= =?UTF-8?q?=EB=AC=B8=EC=A0=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/team7/inplace/place/domain/Menu.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/team7/inplace/place/domain/Menu.java b/src/main/java/team7/inplace/place/domain/Menu.java index 316d6e1c..cd236c03 100644 --- a/src/main/java/team7/inplace/place/domain/Menu.java +++ b/src/main/java/team7/inplace/place/domain/Menu.java @@ -24,7 +24,7 @@ public class Menu { @Column(length = 50) private String menuImgUrl; - + private Menu(Long price, boolean recommend, String menuName) { this.price = price; this.recommend = recommend; @@ -33,7 +33,8 @@ private Menu(Long price, boolean recommend, String menuName) { public static Menu of(String menu) { String[] menus = menu.split("\\|"); - - return new Menu(Long.parseLong(menus[1]), Boolean.parseBoolean(menus[2]), menus[0]); + var price = menus[1].replace(",", ""); + return new Menu(Long.valueOf(price), Boolean.parseBoolean(menus[2]), menus[0]); } + } From 190ebe92b67bd3a0450410012adac2c52ffbddcd Mon Sep 17 00:00:00 2001 From: sanghee0820 Date: Thu, 10 Oct 2024 11:02:05 +0900 Subject: [PATCH 03/20] =?UTF-8?q?[fix]=20=EC=B9=B4=ED=85=8C=EA=B3=A0?= =?UTF-8?q?=EB=A6=AC=EA=B0=80=20db=EC=97=90=20=EC=A7=80=EC=A0=95=EB=90=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EC=95=98=EC=9D=84=20=EA=B2=BD=EC=9A=B0=20?= =?UTF-8?q?NONE=20=EB=B0=98=ED=99=98=20=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team7/inplace/place/domain/Category.java | 26 ++++++++++++++++--- .../team7/inplace/place/domain/Place.java | 2 +- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/main/java/team7/inplace/place/domain/Category.java b/src/main/java/team7/inplace/place/domain/Category.java index 974d1ea7..8469478e 100644 --- a/src/main/java/team7/inplace/place/domain/Category.java +++ b/src/main/java/team7/inplace/place/domain/Category.java @@ -1,8 +1,26 @@ package team7.inplace.place.domain; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor public enum Category { - CAFE, - WESTERN, - JAPANESE, - KOREAN + CAFE("카페"), + WESTERN("양식"), + JAPANESE("일식"), + KOREAN("한식"), + RESTAURANT("음식점"), + NONE("없음"); + + private final String name; + + public static Category of(String name) { + for (Category category : values()) { + if (category.name.equals(name)) { + return category; + } + } + return NONE; + } } diff --git a/src/main/java/team7/inplace/place/domain/Place.java b/src/main/java/team7/inplace/place/domain/Place.java index daa09bdc..1a74c1fa 100644 --- a/src/main/java/team7/inplace/place/domain/Place.java +++ b/src/main/java/team7/inplace/place/domain/Place.java @@ -64,7 +64,7 @@ public Place(String name, String facility, String menuImgsUrl, String category, this.name = name; this.facility = facility; this.menuImgUrl = menuImgsUrl; - this.category = Category.valueOf(category); + this.category = Category.of(category); this.address = Address.of(address); this.coordinate = Coordinate.of(x, y); this.offDays = offDays.stream() From a1355a6091cd7cf38062798d34cda05f34993ff0 Mon Sep 17 00:00:00 2001 From: sanghee0820 Date: Thu, 10 Oct 2024 11:02:24 +0900 Subject: [PATCH 04/20] =?UTF-8?q?[fix]=20=EC=A3=BC=EC=86=8C=20=ED=8C=8C?= =?UTF-8?q?=EC=8B=B1=20=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/team7/inplace/place/domain/Address.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/team7/inplace/place/domain/Address.java b/src/main/java/team7/inplace/place/domain/Address.java index 4482278c..4775adab 100644 --- a/src/main/java/team7/inplace/place/domain/Address.java +++ b/src/main/java/team7/inplace/place/domain/Address.java @@ -4,6 +4,7 @@ import jakarta.persistence.Column; import jakarta.persistence.Embeddable; +import java.util.Arrays; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; @@ -29,7 +30,11 @@ private Address(String address1, String address2, String address3) { } public static Address of(String address) { - String[] split = address.split("\\|"); - return new Address(split[0], split[1], split[2]); + System.out.println("address: " + address); + String[] split = address.split(" "); + var address1 = split[0]; + var address2 = split[1]; + var address3 = String.join(" ", Arrays.copyOfRange(split, 2, split.length)); + return new Address(address1, address2, address3); } } From eab5c3a47b9d943fe63ada87577a0744dbb844f1 Mon Sep 17 00:00:00 2001 From: sanghee0820 Date: Thu, 10 Oct 2024 11:02:59 +0900 Subject: [PATCH 05/20] =?UTF-8?q?[fix]=20place=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EC=B9=B4=ED=85=8C=EA=B3=A0=EB=A6=AC=EB=A5=BC=20=EB=B0=98?= =?UTF-8?q?=ED=99=98=ED=95=98=EB=8A=94=20=ED=95=84=EB=93=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../inplace/place/application/command/PlacesCommand.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/team7/inplace/place/application/command/PlacesCommand.java b/src/main/java/team7/inplace/place/application/command/PlacesCommand.java index 376f2351..13e1fd50 100644 --- a/src/main/java/team7/inplace/place/application/command/PlacesCommand.java +++ b/src/main/java/team7/inplace/place/application/command/PlacesCommand.java @@ -74,8 +74,8 @@ public static Create from(JsonNode locationNode, JsonNode placeNode) { ? basicInfo.get("facilityInfo").toString() : "N/A"; String menuImgUrl = basicInfo.has("mainphotourl") ? basicInfo.get("mainphotourl").asText() : ""; - String category = basicInfo.has("category") && basicInfo.get("category").has("catename") - ? basicInfo.get("category").get("catename").asText() : "Unknown Category"; + String category = basicInfo.has("category") && basicInfo.get("category").has("cate1name") + ? basicInfo.get("category").get("cate1name").asText() : "Unknown Category"; String address = basicInfo.has("address") && basicInfo.get("address").has("region") && basicInfo.get("address") .get("region").has("newaddrfullname") From 2f3144a2b5d5cc3c2783b16cb1b293f616f03a0c Mon Sep 17 00:00:00 2001 From: sanghee0820 Date: Thu, 10 Oct 2024 11:03:26 +0900 Subject: [PATCH 06/20] =?UTF-8?q?[feat]=20=EC=B9=B4=ED=85=8C=EA=B3=A0?= =?UTF-8?q?=EB=A6=AC=20=EC=B6=94=EA=B0=80=EB=A1=9C=20=EC=9D=B8=ED=95=9C=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team7/inplace/video/application/AliasUtil.java | 4 +++- .../team7/inplace/video/application/Template.java | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/team7/inplace/video/application/AliasUtil.java b/src/main/java/team7/inplace/video/application/AliasUtil.java index 02107fa5..679e8017 100644 --- a/src/main/java/team7/inplace/video/application/AliasUtil.java +++ b/src/main/java/team7/inplace/video/application/AliasUtil.java @@ -6,7 +6,7 @@ @RequiredArgsConstructor(access = AccessLevel.PRIVATE) public final class AliasUtil { - public static String makeAlias(String influencerName, Category category){ + public static String makeAlias(String influencerName, Category category) { String alias = mapTemplateToCategory(category); return influencerName + " " + alias; } @@ -18,6 +18,8 @@ private static String mapTemplateToCategory(Category category) { case WESTERN -> Template.WESTERN.getRandomTemplate(); case JAPANESE -> Template.JAPANESE.getRandomTemplate(); case KOREAN -> Template.KOREAN.getRandomTemplate(); + case RESTAURANT -> Template.RESTAURANT.getRandomTemplate(); + default -> Template.NONE.getRandomTemplate(); }; } } diff --git a/src/main/java/team7/inplace/video/application/Template.java b/src/main/java/team7/inplace/video/application/Template.java index b1f2a0d5..aa9da0a4 100644 --- a/src/main/java/team7/inplace/video/application/Template.java +++ b/src/main/java/team7/inplace/video/application/Template.java @@ -30,6 +30,17 @@ public enum Template { "이(가) 전통 한식을 맛볼 수 있는 한식당입니다.", "이(가) 추천하는 가게에서 정성스럽게 준비된 한식으로 든든한 한 끼를!", "이(가) 극찬! 한식의 깊은 맛을 느껴보세요." + }), + + // 기본 템플릿 + RESTAURANT(new String[]{ + "이(가) 추천하는 맛집! 다양한 메뉴를 즐길 수 있습니다.", + "이(가) 방문한 식당에서 맛있는 음식을 즐겨보세요!", + "이(가) 추천하는 맛집에서 특별한 시간을 보내보세요!" + }), + + NONE(new String[]{ + "" }); // 템플릿 배열을 반환하는 메서드 From c248610160611c76e208c6e5780a81e5994c7f4f Mon Sep 17 00:00:00 2001 From: sanghee0820 Date: Thu, 10 Oct 2024 11:44:11 +0900 Subject: [PATCH 07/20] =?UTF-8?q?[fix]=20placeNode=EA=B0=80=20null?= =?UTF-8?q?=EC=9D=BC=20=EA=B2=BD=EC=9A=B0,=20null=EC=9D=84=20=EB=B0=98?= =?UTF-8?q?=ED=99=98=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../inplace/crawling/application/dto/CrawlingInfo.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/team7/inplace/crawling/application/dto/CrawlingInfo.java b/src/main/java/team7/inplace/crawling/application/dto/CrawlingInfo.java index 7ed84962..0bf0a33f 100644 --- a/src/main/java/team7/inplace/crawling/application/dto/CrawlingInfo.java +++ b/src/main/java/team7/inplace/crawling/application/dto/CrawlingInfo.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.databind.JsonNode; import java.util.List; +import java.util.Objects; import team7.inplace.crawling.client.dto.PlaceNode; import team7.inplace.place.application.command.PlacesCommand; import team7.inplace.video.application.command.VideoCommand; @@ -19,7 +20,12 @@ public List toVideoCommands() { public List toPlacesCommands() { return placeNodes.stream() - .map(placeNode -> PlacesCommand.Create.from(placeNode.locationNode(), placeNode.placeNode())) + .map(placeNode -> { + if (Objects.isNull(placeNode)) { + return null; + } + return PlacesCommand.Create.from(placeNode.locationNode(), placeNode.placeNode()); + }) .toList(); } } From 72e97368b98c7627cadb1afa7516283063ebc300 Mon Sep 17 00:00:00 2001 From: sanghee0820 Date: Thu, 10 Oct 2024 11:50:12 +0900 Subject: [PATCH 08/20] =?UTF-8?q?[fix]=20document=EA=B0=80=20=EC=9E=88?= =?UTF-8?q?=EC=A7=80=EB=A7=8C,=20=EC=A0=95=EB=B3=B4=EA=B0=80=20=EC=97=86?= =?UTF-8?q?=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20=EC=A0=9C=EC=99=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/team7/inplace/crawling/client/KakaoMapClient.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/team7/inplace/crawling/client/KakaoMapClient.java b/src/main/java/team7/inplace/crawling/client/KakaoMapClient.java index b56fc71f..d7446d89 100644 --- a/src/main/java/team7/inplace/crawling/client/KakaoMapClient.java +++ b/src/main/java/team7/inplace/crawling/client/KakaoMapClient.java @@ -24,8 +24,9 @@ public class KakaoMapClient { private final RestTemplate restTemplate; public PlaceNode search(String address, String category) { + log.info("KakaoMapClient search address: {}, category: {}", address, category); var locationInfo = getLocateInfo(address, category); - var placeId = locationInfo.has("documents") ? + var placeId = locationInfo.has("documents") && locationInfo.get("documents").hasNonNull(1) ? locationInfo.get("documents").get(0).get("id").asText() : null; if (Objects.isNull(placeId)) { return null; From c34720a9e16c0338faa6be996ea17db6ed568243 Mon Sep 17 00:00:00 2001 From: sanghee0820 Date: Thu, 10 Oct 2024 11:50:40 +0900 Subject: [PATCH 09/20] =?UTF-8?q?[feat]=20price=20=EC=A0=95=EB=B3=B4?= =?UTF-8?q?=EA=B0=80=20=EB=8B=A4=EC=96=91=ED=95=B4=20String=ED=98=95?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=A0=80=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/team7/inplace/place/domain/Menu.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/team7/inplace/place/domain/Menu.java b/src/main/java/team7/inplace/place/domain/Menu.java index cd236c03..f23bfb8f 100644 --- a/src/main/java/team7/inplace/place/domain/Menu.java +++ b/src/main/java/team7/inplace/place/domain/Menu.java @@ -13,7 +13,7 @@ @EqualsAndHashCode @NoArgsConstructor(access = AccessLevel.PROTECTED) public class Menu { - private Long price; + private String price; @ColumnDefault("false") @Column(nullable = false) @@ -25,7 +25,7 @@ public class Menu { @Column(length = 50) private String menuImgUrl; - private Menu(Long price, boolean recommend, String menuName) { + private Menu(String price, boolean recommend, String menuName) { this.price = price; this.recommend = recommend; this.menuName = menuName; @@ -33,8 +33,7 @@ private Menu(Long price, boolean recommend, String menuName) { public static Menu of(String menu) { String[] menus = menu.split("\\|"); - var price = menus[1].replace(",", ""); - return new Menu(Long.valueOf(price), Boolean.parseBoolean(menus[2]), menus[0]); + return new Menu(menus[1], Boolean.parseBoolean(menus[2]), menus[0]); } } From 5574cdea68a99c2d024fa1f41e59884c37a09653 Mon Sep 17 00:00:00 2001 From: sanghee0820 Date: Thu, 10 Oct 2024 19:24:36 +0900 Subject: [PATCH 10/20] =?UTF-8?q?[fix]=20place=EB=A5=BC=20nullable=20?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/team7/inplace/video/domain/Video.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/team7/inplace/video/domain/Video.java b/src/main/java/team7/inplace/video/domain/Video.java index 3b2eada2..08f07438 100644 --- a/src/main/java/team7/inplace/video/domain/Video.java +++ b/src/main/java/team7/inplace/video/domain/Video.java @@ -11,7 +11,6 @@ import jakarta.persistence.ManyToOne; import lombok.Getter; import lombok.NoArgsConstructor; -import lombok.NonNull; import lombok.RequiredArgsConstructor; import team7.inplace.influencer.domain.Influencer; import team7.inplace.place.domain.Place; @@ -26,17 +25,14 @@ public class Video { private Long id; @Column(name = "video_url", nullable = false, columnDefinition = "TEXT") - @NonNull private String videoUrl; @ManyToOne @JoinColumn(name = "influencer_id", nullable = false) - @NonNull private Influencer influencer; @ManyToOne - @JoinColumn(name = "place_id", nullable = false) - @NonNull + @JoinColumn(name = "place_id") private Place place; private Video(Influencer influencer, Place place, String videoUrl) { From c09392a6dd29b4c7412524f5ae3969863f1084a2 Mon Sep 17 00:00:00 2001 From: sanghee0820 Date: Thu, 10 Oct 2024 19:25:58 +0900 Subject: [PATCH 11/20] =?UTF-8?q?[fix]=20null=EC=B2=B4=ED=81=AC=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../inplace/place/application/command/PlacesCommand.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/team7/inplace/place/application/command/PlacesCommand.java b/src/main/java/team7/inplace/place/application/command/PlacesCommand.java index 13e1fd50..d64ef856 100644 --- a/src/main/java/team7/inplace/place/application/command/PlacesCommand.java +++ b/src/main/java/team7/inplace/place/application/command/PlacesCommand.java @@ -66,6 +66,10 @@ public Place toEntity() { } public static Create from(JsonNode locationNode, JsonNode placeNode) { + if (Objects.isNull(locationNode) || Objects.isNull(placeNode)) { + return null; + } + var basicInfo = placeNode.get("basicInfo"); String placeName = From 08419a5f3f015942f87f0480c2be35f9402cb298 Mon Sep 17 00:00:00 2001 From: sanghee0820 Date: Thu, 10 Oct 2024 19:26:26 +0900 Subject: [PATCH 12/20] =?UTF-8?q?[feat]=20price=EB=A5=BC=20String=20?= =?UTF-8?q?=ED=98=95=EC=9C=BC=EB=A1=9C=20=EB=B3=80=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team7/inplace/place/application/dto/PlaceDetailInfo.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/team7/inplace/place/application/dto/PlaceDetailInfo.java b/src/main/java/team7/inplace/place/application/dto/PlaceDetailInfo.java index a68cfee7..93410b68 100644 --- a/src/main/java/team7/inplace/place/application/dto/PlaceDetailInfo.java +++ b/src/main/java/team7/inplace/place/application/dto/PlaceDetailInfo.java @@ -52,7 +52,7 @@ public static MenuInfos of(List menus) { .toList(); List menuList = menus.stream() - .map(menu -> new MenuInfo(menu.getPrice().intValue(), menu.isRecommend(), + .map(menu -> new MenuInfo(menu.getPrice(), menu.isRecommend(), menu.getMenuName())) .toList(); @@ -60,7 +60,7 @@ public static MenuInfos of(List menus) { } public record MenuInfo( - Integer price, + String price, Boolean recommend, String menuName ) { From 333751ae4e593dddd4f12c0e923e26cc20d03e5f Mon Sep 17 00:00:00 2001 From: sanghee0820 Date: Thu, 10 Oct 2024 19:43:15 +0900 Subject: [PATCH 13/20] =?UTF-8?q?[feat]=20RequiredArgsConstructor=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/team7/inplace/video/domain/Video.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/team7/inplace/video/domain/Video.java b/src/main/java/team7/inplace/video/domain/Video.java index 08f07438..303982ac 100644 --- a/src/main/java/team7/inplace/video/domain/Video.java +++ b/src/main/java/team7/inplace/video/domain/Video.java @@ -11,14 +11,12 @@ import jakarta.persistence.ManyToOne; import lombok.Getter; import lombok.NoArgsConstructor; -import lombok.RequiredArgsConstructor; import team7.inplace.influencer.domain.Influencer; import team7.inplace.place.domain.Place; @Entity @Getter @NoArgsConstructor(access = PROTECTED) -@RequiredArgsConstructor public class Video { @Id @GeneratedValue(strategy = IDENTITY) From 5e163e866754959e9df0803272156f63ae847dd6 Mon Sep 17 00:00:00 2001 From: sanghee0820 Date: Thu, 10 Oct 2024 19:43:44 +0900 Subject: [PATCH 14/20] =?UTF-8?q?[feat]=20Enumerate=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/team7/inplace/crawling/domain/YoutubeChannel.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/team7/inplace/crawling/domain/YoutubeChannel.java b/src/main/java/team7/inplace/crawling/domain/YoutubeChannel.java index 00f94f9e..1fadeab8 100644 --- a/src/main/java/team7/inplace/crawling/domain/YoutubeChannel.java +++ b/src/main/java/team7/inplace/crawling/domain/YoutubeChannel.java @@ -1,6 +1,9 @@ package team7.inplace.crawling.domain; +import static jakarta.persistence.EnumType.STRING; + import jakarta.persistence.Entity; +import jakarta.persistence.Enumerated; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; @@ -22,6 +25,7 @@ public class YoutubeChannel { private String playListUUID; private String lastVideoUUID; + @Enumerated(value = STRING) private ChannelType channelType; public String getChannelTypeCode() { From 9f4bc4500b464e203ce4450c13d4064f1c29082c Mon Sep 17 00:00:00 2001 From: sanghee0820 Date: Thu, 10 Oct 2024 20:31:10 +0900 Subject: [PATCH 15/20] =?UTF-8?q?[feat]=20menu=20img=EC=99=80=20descriptio?= =?UTF-8?q?n=EC=9D=84=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/command/PlacesCommand.java | 18 +++++++++++------- .../java/team7/inplace/place/domain/Menu.java | 9 ++++++--- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/main/java/team7/inplace/place/application/command/PlacesCommand.java b/src/main/java/team7/inplace/place/application/command/PlacesCommand.java index d64ef856..1b20da31 100644 --- a/src/main/java/team7/inplace/place/application/command/PlacesCommand.java +++ b/src/main/java/team7/inplace/place/application/command/PlacesCommand.java @@ -69,7 +69,7 @@ public static Create from(JsonNode locationNode, JsonNode placeNode) { if (Objects.isNull(locationNode) || Objects.isNull(placeNode)) { return null; } - + var basicInfo = placeNode.get("basicInfo"); String placeName = @@ -186,21 +186,25 @@ public String toEntityParams() { public record Menu( String menuName, String menuPrice, - boolean recommend + boolean recommend, + String menuImgUrl, + String description ) { public static Menu from(JsonNode menuNode) { if (Objects.isNull(menuNode)) { - return new Menu("Unknown Menu", "0", false); + return new Menu("Unknown Menu", "0", false, "", ""); } - String menuName = menuNode.has("menu") ? menuNode.get("menu").asText() : "Unknown Menu"; - String menuPrice = menuNode.has("price") ? menuNode.get("price").asText() : "0"; + String menuName = menuNode.has("menu") ? menuNode.get("menu").asText() : " "; + String menuPrice = menuNode.has("price") ? menuNode.get("price").asText() : " "; boolean recommend = menuNode.has("recommend") && menuNode.get("recommend").asBoolean(); + String menuImgUrl = menuNode.has("img") ? menuNode.get("img").asText() : " "; + String description = menuNode.has("desc") ? menuNode.get("desc").asText() : " "; - return new Menu(menuName, menuPrice, recommend); + return new Menu(menuName, menuPrice, recommend, menuImgUrl, description); } public String toEntityParams() { - return menuName + "|" + menuPrice + "|" + recommend; + return menuName + "|" + menuPrice + "|" + recommend + "|" + menuImgUrl + "|" + description; } } } diff --git a/src/main/java/team7/inplace/place/domain/Menu.java b/src/main/java/team7/inplace/place/domain/Menu.java index f23bfb8f..1b8cee65 100644 --- a/src/main/java/team7/inplace/place/domain/Menu.java +++ b/src/main/java/team7/inplace/place/domain/Menu.java @@ -22,18 +22,21 @@ public class Menu { @Column(length = 50, nullable = false) private String menuName; - @Column(length = 50) private String menuImgUrl; - private Menu(String price, boolean recommend, String menuName) { + private String description; + + private Menu(String price, boolean recommend, String menuName, String menuImgUrl, String description) { this.price = price; this.recommend = recommend; this.menuName = menuName; + this.menuImgUrl = menuImgUrl; + this.description = description; } public static Menu of(String menu) { String[] menus = menu.split("\\|"); - return new Menu(menus[1], Boolean.parseBoolean(menus[2]), menus[0]); + return new Menu(menus[1], Boolean.parseBoolean(menus[2]), menus[0], menus[3], menus[4]); } } From 6a1ed7d93d34fbccda7e169a9461a03b62c0c84c Mon Sep 17 00:00:00 2001 From: sanghee0820 Date: Thu, 10 Oct 2024 20:52:55 +0900 Subject: [PATCH 16/20] =?UTF-8?q?[feat]=20JsonNode=EC=99=80=20String=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../inplace/crawling/application/AddressUtil.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/team7/inplace/crawling/application/AddressUtil.java b/src/main/java/team7/inplace/crawling/application/AddressUtil.java index ad241ebd..cfe07276 100644 --- a/src/main/java/team7/inplace/crawling/application/AddressUtil.java +++ b/src/main/java/team7/inplace/crawling/application/AddressUtil.java @@ -8,15 +8,19 @@ import lombok.NoArgsConstructor; @NoArgsConstructor(access = PRIVATE) -public class AddressUtil { - private static final String ADDRESS_REGEX = "[가-힣0-9]+(?:도|시|구|군|읍|면|동|리|로|길)[^#,\\n()]+(?:동|읍|면|리|로|길)[^#]?"; +public final class AddressUtil { + private static final String ADDRESS_REGEX = "[가-힣0-9]+(?:도|시|구|군|읍|면|동|리|로|길)\\s*[0-9]*(?:동|읍|면|리|로|길)?\\s*[0-9]+"; - public static String extractAddress(JsonNode snippet) { + public static String extractAddressFromJsonNode(JsonNode snippet) { String videoDescription = snippet.path("description").asText(); + return extractAddressFromString(videoDescription); + } + + public static String extractAddressFromString(String string) { Pattern pattern = Pattern.compile(ADDRESS_REGEX); - Matcher matcher = pattern.matcher(videoDescription); + Matcher matcher = pattern.matcher(string); if (matcher.find()) { return matcher.group(); } From e10ed326e998f6c6cb83c1d56f7fe0bcd0b372a1 Mon Sep 17 00:00:00 2001 From: sanghee0820 Date: Thu, 10 Oct 2024 21:01:47 +0900 Subject: [PATCH 17/20] =?UTF-8?q?[fix]=20=ED=94=84=EB=A6=B0=EB=AC=B8=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/team7/inplace/place/domain/Address.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/team7/inplace/place/domain/Address.java b/src/main/java/team7/inplace/place/domain/Address.java index 4775adab..2212008b 100644 --- a/src/main/java/team7/inplace/place/domain/Address.java +++ b/src/main/java/team7/inplace/place/domain/Address.java @@ -30,11 +30,10 @@ private Address(String address1, String address2, String address3) { } public static Address of(String address) { - System.out.println("address: " + address); String[] split = address.split(" "); var address1 = split[0]; var address2 = split[1]; var address3 = String.join(" ", Arrays.copyOfRange(split, 2, split.length)); return new Address(address1, address2, address3); } -} +} \ No newline at end of file From eb76ff5895f99ce5206ec3a5e6c23ea45b2987e1 Mon Sep 17 00:00:00 2001 From: sanghee0820 Date: Thu, 10 Oct 2024 21:02:17 +0900 Subject: [PATCH 18/20] =?UTF-8?q?[test]=20=EC=A3=BC=EC=86=8C=20=ED=8C=8C?= =?UTF-8?q?=EC=8B=B1=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../crawling/application/AddressUtilTest.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/test/java/team7/inplace/crawling/application/AddressUtilTest.java diff --git a/src/test/java/team7/inplace/crawling/application/AddressUtilTest.java b/src/test/java/team7/inplace/crawling/application/AddressUtilTest.java new file mode 100644 index 00000000..6adcf7cf --- /dev/null +++ b/src/test/java/team7/inplace/crawling/application/AddressUtilTest.java @@ -0,0 +1,27 @@ +package team7.inplace.crawling.application; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +class AddressUtilTest { + + @DisplayName("주소 추출 테스트 1") + @Test + void extractAddressFromJsonNodeTest1() { + // given + final String description = """ + [참조은 생고기] + 대구 북구 복현로 78 (복현2동 266-9) + """; + final String address = "대구 북구 복현로 78"; + + // when + String result = AddressUtil.extractAddressFromString(description); + + // then + assertEquals(address, result); + } + +} \ No newline at end of file From 47b40212dc3ee47a518aaf51579c61c43667a943 Mon Sep 17 00:00:00 2001 From: sanghee0820 Date: Thu, 10 Oct 2024 21:02:37 +0900 Subject: [PATCH 19/20] =?UTF-8?q?[fix]=20null=ED=99=95=EC=9D=B8=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=EC=9D=84=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../inplace/place/application/command/PlacesCommand.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/team7/inplace/place/application/command/PlacesCommand.java b/src/main/java/team7/inplace/place/application/command/PlacesCommand.java index 1b20da31..5d7d4559 100644 --- a/src/main/java/team7/inplace/place/application/command/PlacesCommand.java +++ b/src/main/java/team7/inplace/place/application/command/PlacesCommand.java @@ -96,8 +96,12 @@ public static Create from(JsonNode locationNode, JsonNode placeNode) { ? locationNode.get("documents").get(0).get("y").asText() : "0.0"; var timeList = basicInfo.has("openHour") ? basicInfo.get("openHour") : null; - var openPeriods = extractOpenPeriods(timeList.has("periodList") ? timeList.get("periodList") : null); - var offDays = extractOffDays(timeList.has("offdayList") ? timeList.get("offdayList") : null); + List openPeriods = Objects.nonNull(timeList) ? + extractOpenPeriods(timeList.has("periodList") ? timeList.get("periodList") : null) + : new ArrayList<>(); + List offDays = Objects.nonNull(timeList) ? + extractOffDays(timeList.has("offdayList") ? timeList.get("offdayList") : null) : new ArrayList<>(); + var menus = extractMenus(placeNode.has("menuInfo") ? placeNode.get("menuInfo") : null); var menuUpdatedAt = placeNode.has("menuInfo") && placeNode.get("menuInfo").has("menuUpdatedAt") ? LocalDateTime.parse(placeNode.get("menuInfo").get("timeexp").asText()) From 10efe63e19383154c08b92948e3a2d856c5089eb Mon Sep 17 00:00:00 2001 From: sanghee0820 Date: Thu, 10 Oct 2024 21:02:54 +0900 Subject: [PATCH 20/20] =?UTF-8?q?[feat]=20JsonNode=EC=99=80=20String=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../inplace/crawling/application/YoutubeCrawlingService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/team7/inplace/crawling/application/YoutubeCrawlingService.java b/src/main/java/team7/inplace/crawling/application/YoutubeCrawlingService.java index 9a3020d1..9b207d73 100644 --- a/src/main/java/team7/inplace/crawling/application/YoutubeCrawlingService.java +++ b/src/main/java/team7/inplace/crawling/application/YoutubeCrawlingService.java @@ -32,7 +32,7 @@ public List crawlAllVideos() { var videoSnippets = youtubeClient.getVideos(channel.getPlayListUUID(), channel.getLastVideoUUID()); var videoAddresses = videoSnippets.stream() - .map(AddressUtil::extractAddress) + .map(AddressUtil::extractAddressFromJsonNode) .toList(); var placeNodes = videoAddresses.stream()