From 142de3f5811037ab24ed7379cf59eb00b0e94254 Mon Sep 17 00:00:00 2001 From: msk226 Date: Mon, 24 Mar 2025 12:37:07 +0900 Subject: [PATCH 01/16] =?UTF-8?q?[FEATURE]=20Dockerfile=20=EC=9B=90?= =?UTF-8?q?=EC=83=81=20=EB=B3=B5=EA=B7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 293f04c..b1ed69c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,5 @@ FROM openjdk:21-jdk-slim -RUN apt-get update && apt-get install -y netcat-openbsd && rm -rf /var/lib/apt/lists/* - COPY /build/libs/capstone-0.0.1-SNAPSHOT.jar app.jar -CMD ["java", "-jar", "app.jar"] +CMD ["java", "-jar", "app.jar"] \ No newline at end of file From 9f02a4b10edf9f8fb154607f0493c3deac8f8929 Mon Sep 17 00:00:00 2001 From: msk226 Date: Mon, 24 Mar 2025 13:04:34 +0900 Subject: [PATCH 02/16] =?UTF-8?q?[FEATURE]=20=ED=8A=B8=EB=9E=9C=EC=9E=AD?= =?UTF-8?q?=EC=85=98=20=EC=BB=A4=EB=B0=8B=20=EA=B0=95=EC=A0=9C=ED=95=98?= =?UTF-8?q?=EA=B8=B0=20=EC=9C=84=ED=95=B4=20flush=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../capstone/service/style/impl/StyleCommandServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/hyu/erica/capstone/service/style/impl/StyleCommandServiceImpl.java b/src/main/java/hyu/erica/capstone/service/style/impl/StyleCommandServiceImpl.java index e3345ec..48bef2a 100644 --- a/src/main/java/hyu/erica/capstone/service/style/impl/StyleCommandServiceImpl.java +++ b/src/main/java/hyu/erica/capstone/service/style/impl/StyleCommandServiceImpl.java @@ -86,7 +86,7 @@ public TripPlanResponseDTO submitStyle(Long styleId, Long userId) { .build(); TripPlan saved = tripPlanRepository.save(tripPlan); - entityManager.flush(); + tripPlanRepository.flush(); // 비동기 처리 시작 asyncService.handleTripPlanDetails(saved.getId(), style, user); From de1f6897c25219fd832650de8ecf7f65ba3270c5 Mon Sep 17 00:00:00 2001 From: msk226 Date: Mon, 24 Mar 2025 13:22:51 +0900 Subject: [PATCH 03/16] =?UTF-8?q?[FEATURE]=20=EC=B6=94=EC=B2=9C=20?= =?UTF-8?q?=EC=97=AC=ED=96=89=EC=A7=80=20=EB=B0=8F=20=EC=8B=9D=EB=8B=B9=20?= =?UTF-8?q?=EC=B5=9C=EC=A2=85=20=EC=84=A0=ED=83=9D=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/mapping/PreferAttraction.java | 2 + .../domain/mapping/PreferRestaurant.java | 2 + .../tripPlan/TripPlanCommandService.java | 5 ++ .../impl/TripPlanCommandServiceImpl.java | 51 +++++++++++++++++++ 4 files changed, 60 insertions(+) create mode 100644 src/main/java/hyu/erica/capstone/service/tripPlan/impl/TripPlanCommandServiceImpl.java diff --git a/src/main/java/hyu/erica/capstone/domain/mapping/PreferAttraction.java b/src/main/java/hyu/erica/capstone/domain/mapping/PreferAttraction.java index b8c2200..df3a7c1 100644 --- a/src/main/java/hyu/erica/capstone/domain/mapping/PreferAttraction.java +++ b/src/main/java/hyu/erica/capstone/domain/mapping/PreferAttraction.java @@ -19,6 +19,7 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; +import lombok.Setter; import org.hibernate.annotations.DynamicInsert; import org.hibernate.annotations.DynamicUpdate; @@ -42,6 +43,7 @@ public class PreferAttraction extends BaseEntity { @JoinColumn(name = "user_id") private User user; + @Setter private boolean isPrefer; diff --git a/src/main/java/hyu/erica/capstone/domain/mapping/PreferRestaurant.java b/src/main/java/hyu/erica/capstone/domain/mapping/PreferRestaurant.java index f69b16b..dd25279 100644 --- a/src/main/java/hyu/erica/capstone/domain/mapping/PreferRestaurant.java +++ b/src/main/java/hyu/erica/capstone/domain/mapping/PreferRestaurant.java @@ -18,6 +18,7 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; +import lombok.Setter; import org.hibernate.annotations.DynamicInsert; import org.hibernate.annotations.DynamicUpdate; @@ -41,6 +42,7 @@ public class PreferRestaurant extends BaseEntity { @JoinColumn(name = "user_id") private User user; + @Setter private boolean isPrefer; @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) diff --git a/src/main/java/hyu/erica/capstone/service/tripPlan/TripPlanCommandService.java b/src/main/java/hyu/erica/capstone/service/tripPlan/TripPlanCommandService.java index 2920336..2b80a40 100644 --- a/src/main/java/hyu/erica/capstone/service/tripPlan/TripPlanCommandService.java +++ b/src/main/java/hyu/erica/capstone/service/tripPlan/TripPlanCommandService.java @@ -1,6 +1,11 @@ package hyu.erica.capstone.service.tripPlan; +import hyu.erica.capstone.web.dto.trip.request.SaveAttractionRequestDTO; +import hyu.erica.capstone.web.dto.trip.request.SaveRestaurantRequestDTO; + public interface TripPlanCommandService { + Long confirmAttractionRecommendation(Long tripPlanId, SaveAttractionRequestDTO request); + Long confirmRestaurantRecommendation(Long tripPlanId, SaveRestaurantRequestDTO request); } diff --git a/src/main/java/hyu/erica/capstone/service/tripPlan/impl/TripPlanCommandServiceImpl.java b/src/main/java/hyu/erica/capstone/service/tripPlan/impl/TripPlanCommandServiceImpl.java new file mode 100644 index 0000000..1878dc2 --- /dev/null +++ b/src/main/java/hyu/erica/capstone/service/tripPlan/impl/TripPlanCommandServiceImpl.java @@ -0,0 +1,51 @@ +package hyu.erica.capstone.service.tripPlan.impl; + +import hyu.erica.capstone.domain.mapping.PreferAttraction; +import hyu.erica.capstone.domain.mapping.PreferRestaurant; +import hyu.erica.capstone.repository.PreferAttractionRepository; +import hyu.erica.capstone.repository.PreferRestaurantRepository; +import hyu.erica.capstone.repository.TripPlanRepository; +import hyu.erica.capstone.repository.UserRepository; +import hyu.erica.capstone.service.tripPlan.TripPlanCommandService; +import hyu.erica.capstone.web.dto.trip.request.SaveAttractionRequestDTO; +import hyu.erica.capstone.web.dto.trip.request.SaveRestaurantRequestDTO; +import java.util.List; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Transactional +@RequiredArgsConstructor +public class TripPlanCommandServiceImpl implements TripPlanCommandService { + + private final PreferAttractionRepository preferAttractionRepository; + private final PreferRestaurantRepository preferRestaurantRepository; + private final TripPlanRepository tripPlanRepository; + + @Override + public Long confirmAttractionRecommendation(Long tripPlanId, SaveAttractionRequestDTO request) { + List preferAttractions = preferAttractionRepository.findAllByTripPlanId(tripPlanId); + + for (PreferAttraction preferAttraction : preferAttractions) { + if (!request.attractionIds().contains(preferAttraction.getId())) { + preferAttraction.setPrefer(false); + } + } + + return tripPlanId; + } + + @Override + public Long confirmRestaurantRecommendation(Long tripPlanId, SaveRestaurantRequestDTO request) { + List preferRestaurants = preferRestaurantRepository.findAllByTripPlanId(tripPlanId); + + for (PreferRestaurant preferRestaurant : preferRestaurants) { + if (!request.restaurantIds().contains(preferRestaurant.getId())) { + preferRestaurant.setPrefer(false); + } + } + + return tripPlanId; + } +} From c4300945c4d6691e2dab53c752459d4efde76415 Mon Sep 17 00:00:00 2001 From: msk226 Date: Mon, 24 Mar 2025 13:25:14 +0900 Subject: [PATCH 04/16] =?UTF-8?q?[FEATURE]=20=EC=B6=94=EC=B2=9C=20?= =?UTF-8?q?=EC=97=AC=ED=96=89=EC=A7=80=20=EB=B0=8F=20=EC=8B=9D=EB=8B=B9=20?= =?UTF-8?q?=EC=B5=9C=EC=A2=85=20=EC=84=A0=ED=83=9D=20API=20=EC=97=B0?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/tripPlan/impl/TripPlanCommandServiceImpl.java | 4 ++-- .../erica/capstone/web/controller/TripPlanController.java | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/hyu/erica/capstone/service/tripPlan/impl/TripPlanCommandServiceImpl.java b/src/main/java/hyu/erica/capstone/service/tripPlan/impl/TripPlanCommandServiceImpl.java index 1878dc2..4cf28be 100644 --- a/src/main/java/hyu/erica/capstone/service/tripPlan/impl/TripPlanCommandServiceImpl.java +++ b/src/main/java/hyu/erica/capstone/service/tripPlan/impl/TripPlanCommandServiceImpl.java @@ -28,7 +28,7 @@ public Long confirmAttractionRecommendation(Long tripPlanId, SaveAttractionReque List preferAttractions = preferAttractionRepository.findAllByTripPlanId(tripPlanId); for (PreferAttraction preferAttraction : preferAttractions) { - if (!request.attractionIds().contains(preferAttraction.getId())) { + if (!request.attractionIds().contains(preferAttraction.getAttraction().getContentId())) { preferAttraction.setPrefer(false); } } @@ -41,7 +41,7 @@ public Long confirmRestaurantRecommendation(Long tripPlanId, SaveRestaurantReque List preferRestaurants = preferRestaurantRepository.findAllByTripPlanId(tripPlanId); for (PreferRestaurant preferRestaurant : preferRestaurants) { - if (!request.restaurantIds().contains(preferRestaurant.getId())) { + if (!request.restaurantIds().contains(preferRestaurant.getRestaurant().getId())) { preferRestaurant.setPrefer(false); } } diff --git a/src/main/java/hyu/erica/capstone/web/controller/TripPlanController.java b/src/main/java/hyu/erica/capstone/web/controller/TripPlanController.java index 31824e4..0a7f364 100644 --- a/src/main/java/hyu/erica/capstone/web/controller/TripPlanController.java +++ b/src/main/java/hyu/erica/capstone/web/controller/TripPlanController.java @@ -2,6 +2,7 @@ import hyu.erica.capstone.api.ApiResponse; import hyu.erica.capstone.api.code.status.SuccessStatus; +import hyu.erica.capstone.service.tripPlan.TripPlanCommandService; import hyu.erica.capstone.service.tripPlan.TripPlanQueryService; import hyu.erica.capstone.web.dto.trip.request.AdditionalInfoRequestDTO; import hyu.erica.capstone.web.dto.trip.request.PreferActivitiesRequestDTO; @@ -30,6 +31,7 @@ public class TripPlanController { private final TripPlanQueryService tripPlanQueryService; + private final TripPlanCommandService tripPlanCommandService; // 선택지 확인 (여행지) @@ -95,7 +97,7 @@ public ApiResponse finalPlace( @PathVariable Long tripPlansId, @RequestBody SaveAttractionRequestDTO request) { // 여행지 최종 선택 - return null; + return ApiResponse.onSuccess(SuccessStatus._OK, tripPlanCommandService.confirmAttractionRecommendation(tripPlansId, request)); } // 선택지 확인 (음식점) @@ -163,7 +165,7 @@ public ApiResponse finalRestaurant( @PathVariable Long tripPlansId, @RequestBody SaveRestaurantRequestDTO request) { // 음식점 최종 선택 - return null; + return ApiResponse.onSuccess(SuccessStatus._OK, tripPlanCommandService.confirmRestaurantRecommendation(tripPlansId, request)); } From d6293c23ef656fc3e563ba0701c55cd65e214da9 Mon Sep 17 00:00:00 2001 From: msk226 Date: Mon, 24 Mar 2025 13:28:25 +0900 Subject: [PATCH 05/16] =?UTF-8?q?[FEATURE]=20=EC=B6=94=EC=B2=9C=20?= =?UTF-8?q?=EC=97=AC=ED=96=89=EC=A7=80=20=EB=B0=8F=20=EC=8B=9D=EB=8B=B9=20?= =?UTF-8?q?=EC=B5=9C=EC=A2=85=20=EC=84=A0=ED=83=9D=20API=20=EB=AA=85?= =?UTF-8?q?=EC=84=B8=EC=84=9C=20=EC=83=81=20[=EA=B0=9C=EB=B0=9C=20?= =?UTF-8?q?=EC=A4=91]=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hyu/erica/capstone/web/controller/TripPlanController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/hyu/erica/capstone/web/controller/TripPlanController.java b/src/main/java/hyu/erica/capstone/web/controller/TripPlanController.java index 0a7f364..7873932 100644 --- a/src/main/java/hyu/erica/capstone/web/controller/TripPlanController.java +++ b/src/main/java/hyu/erica/capstone/web/controller/TripPlanController.java @@ -84,7 +84,7 @@ public ApiResponse searchPlace( } // 여행지 최종 선택 - @Tag(name = "[개발 전] 선택지 확인", description = "선택지 확인 API") + @Tag(name = "선택지 확인", description = "선택지 확인 API") @Operation(summary = "여행지 최종 선택", description = """ ### 여행지 최종 선택 API @@ -153,7 +153,7 @@ public ApiResponse searchRestaurant( // 음식점 최종 선택 - @Tag(name = "[개발 전] 선택지 확인", description = "선택지 확인 API") + @Tag(name = "선택지 확인", description = "선택지 확인 API") @Operation(summary = "음식점 최종 선택", description = """ ### 음식점 최종 선택 API From 3a2ddeacdca73d0e52c0d2e3b89c623a1e53121d Mon Sep 17 00:00:00 2001 From: msk226 Date: Mon, 24 Mar 2025 13:38:30 +0900 Subject: [PATCH 06/16] =?UTF-8?q?[FEATURE]=20=EC=9D=91=EB=8B=B5=20DTO=20?= =?UTF-8?q?=EB=94=94=EB=A0=89=ED=86=A0=EB=A6=AC=20=EA=B5=AC=EC=A1=B0=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 --- .../response/{ => attraction}/AttractionDetailResponseDTO.java | 2 +- .../response/{ => attraction}/AttractionListResponseDTO.java | 2 +- .../response/{ => attraction}/AttractionResponseDTO.java | 2 +- .../response/{ => attraction}/AttractionSearchResponseDTO.java | 2 +- .../response/{ => restaurant}/RestaurantDetailResponseDTO.java | 2 +- .../response/{ => restaurant}/RestaurantListResponseDTO.java | 2 +- .../response/{ => restaurant}/RestaurantResponseDTO.java | 2 +- .../response/{ => restaurant}/RestaurantSearchResponseDTO.java | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) rename src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/{ => attraction}/AttractionDetailResponseDTO.java (89%) rename src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/{ => attraction}/AttractionListResponseDTO.java (89%) rename src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/{ => attraction}/AttractionResponseDTO.java (80%) rename src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/{ => attraction}/AttractionSearchResponseDTO.java (93%) rename src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/{ => restaurant}/RestaurantDetailResponseDTO.java (89%) rename src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/{ => restaurant}/RestaurantListResponseDTO.java (89%) rename src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/{ => restaurant}/RestaurantResponseDTO.java (83%) rename src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/{ => restaurant}/RestaurantSearchResponseDTO.java (93%) diff --git a/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/AttractionDetailResponseDTO.java b/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/attraction/AttractionDetailResponseDTO.java similarity index 89% rename from src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/AttractionDetailResponseDTO.java rename to src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/attraction/AttractionDetailResponseDTO.java index 2bccf00..20bf3aa 100644 --- a/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/AttractionDetailResponseDTO.java +++ b/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/attraction/AttractionDetailResponseDTO.java @@ -1,4 +1,4 @@ -package hyu.erica.capstone.web.dto.tripPlan.response; +package hyu.erica.capstone.web.dto.tripPlan.response.attraction; import hyu.erica.capstone.domain.Attraction; diff --git a/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/AttractionListResponseDTO.java b/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/attraction/AttractionListResponseDTO.java similarity index 89% rename from src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/AttractionListResponseDTO.java rename to src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/attraction/AttractionListResponseDTO.java index da53553..142a685 100644 --- a/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/AttractionListResponseDTO.java +++ b/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/attraction/AttractionListResponseDTO.java @@ -1,4 +1,4 @@ -package hyu.erica.capstone.web.dto.tripPlan.response; +package hyu.erica.capstone.web.dto.tripPlan.response.attraction; import hyu.erica.capstone.domain.Attraction; import java.util.List; diff --git a/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/AttractionResponseDTO.java b/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/attraction/AttractionResponseDTO.java similarity index 80% rename from src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/AttractionResponseDTO.java rename to src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/attraction/AttractionResponseDTO.java index c270ff5..0dc28d2 100644 --- a/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/AttractionResponseDTO.java +++ b/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/attraction/AttractionResponseDTO.java @@ -1,4 +1,4 @@ -package hyu.erica.capstone.web.dto.tripPlan.response; +package hyu.erica.capstone.web.dto.tripPlan.response.attraction; public record AttractionResponseDTO(Long attractionId, String name, String imageUrl) { diff --git a/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/AttractionSearchResponseDTO.java b/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/attraction/AttractionSearchResponseDTO.java similarity index 93% rename from src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/AttractionSearchResponseDTO.java rename to src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/attraction/AttractionSearchResponseDTO.java index 593289a..ac9c163 100644 --- a/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/AttractionSearchResponseDTO.java +++ b/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/attraction/AttractionSearchResponseDTO.java @@ -1,4 +1,4 @@ -package hyu.erica.capstone.web.dto.tripPlan.response; +package hyu.erica.capstone.web.dto.tripPlan.response.attraction; import hyu.erica.capstone.domain.Attraction; import java.util.ArrayList; diff --git a/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/RestaurantDetailResponseDTO.java b/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/restaurant/RestaurantDetailResponseDTO.java similarity index 89% rename from src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/RestaurantDetailResponseDTO.java rename to src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/restaurant/RestaurantDetailResponseDTO.java index abd7bb0..952dfa5 100644 --- a/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/RestaurantDetailResponseDTO.java +++ b/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/restaurant/RestaurantDetailResponseDTO.java @@ -1,4 +1,4 @@ -package hyu.erica.capstone.web.dto.tripPlan.response; +package hyu.erica.capstone.web.dto.tripPlan.response.restaurant; import hyu.erica.capstone.domain.Restaurant; diff --git a/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/RestaurantListResponseDTO.java b/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/restaurant/RestaurantListResponseDTO.java similarity index 89% rename from src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/RestaurantListResponseDTO.java rename to src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/restaurant/RestaurantListResponseDTO.java index 0b079a0..c4cb260 100644 --- a/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/RestaurantListResponseDTO.java +++ b/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/restaurant/RestaurantListResponseDTO.java @@ -1,4 +1,4 @@ -package hyu.erica.capstone.web.dto.tripPlan.response; +package hyu.erica.capstone.web.dto.tripPlan.response.restaurant; import hyu.erica.capstone.domain.Restaurant; import java.util.ArrayList; diff --git a/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/RestaurantResponseDTO.java b/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/restaurant/RestaurantResponseDTO.java similarity index 83% rename from src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/RestaurantResponseDTO.java rename to src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/restaurant/RestaurantResponseDTO.java index ebe2633..95aeb84 100644 --- a/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/RestaurantResponseDTO.java +++ b/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/restaurant/RestaurantResponseDTO.java @@ -1,4 +1,4 @@ -package hyu.erica.capstone.web.dto.tripPlan.response; +package hyu.erica.capstone.web.dto.tripPlan.response.restaurant; import hyu.erica.capstone.domain.Restaurant; diff --git a/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/RestaurantSearchResponseDTO.java b/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/restaurant/RestaurantSearchResponseDTO.java similarity index 93% rename from src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/RestaurantSearchResponseDTO.java rename to src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/restaurant/RestaurantSearchResponseDTO.java index 75fda81..4bf332e 100644 --- a/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/RestaurantSearchResponseDTO.java +++ b/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/restaurant/RestaurantSearchResponseDTO.java @@ -1,4 +1,4 @@ -package hyu.erica.capstone.web.dto.tripPlan.response; +package hyu.erica.capstone.web.dto.tripPlan.response.restaurant; import hyu.erica.capstone.domain.Restaurant; import java.util.ArrayList; From 1377c0e699136b230aadd3e4bfba8c102c486a6c Mon Sep 17 00:00:00 2001 From: msk226 Date: Mon, 24 Mar 2025 13:55:30 +0900 Subject: [PATCH 07/16] =?UTF-8?q?[FEATURE]=20=EC=97=AC=ED=96=89=20?= =?UTF-8?q?=EA=B3=84=ED=9A=8D=20=EA=B0=9C=EB=B3=84=20=EC=95=84=EC=9D=B4?= =?UTF-8?q?=ED=85=9C=20=EC=A0=80=EC=9E=A5=20=EC=9C=84=ED=95=9C=20=EC=97=94?= =?UTF-8?q?=ED=8B=B0=ED=8B=B0=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../capstone/domain/TripScheduleItem.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/main/java/hyu/erica/capstone/domain/TripScheduleItem.java diff --git a/src/main/java/hyu/erica/capstone/domain/TripScheduleItem.java b/src/main/java/hyu/erica/capstone/domain/TripScheduleItem.java new file mode 100644 index 0000000..cc53b56 --- /dev/null +++ b/src/main/java/hyu/erica/capstone/domain/TripScheduleItem.java @@ -0,0 +1,51 @@ +package hyu.erica.capstone.domain; + +import static jakarta.persistence.EnumType.*; +import static jakarta.persistence.GenerationType.IDENTITY; + +import hyu.erica.capstone.domain.enums.PlaceType; +import jakarta.persistence.Entity; +import jakarta.persistence.Enumerated; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Entity +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor +@Builder +public class TripScheduleItem { + + @Id + @GeneratedValue(strategy = IDENTITY) + private Long id; + + private int dayNumber; // 1일차, 2일차 등 + + private int orderInDay; // 순서: 1, 2, 3 ... + + private String memo; + + @Enumerated(value = STRING) + private PlaceType placeType; // ATTRACTION, RESTAURANT + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "trip_plan_id") + private TripPlan tripPlan; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "attraction_id") + private Attraction attraction; // nullable + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "restaurant_id") + private Restaurant restaurant; // nullable +} From 629c15a17e430f0f547a11a1b7eece58252a0cdf Mon Sep 17 00:00:00 2001 From: msk226 Date: Mon, 24 Mar 2025 13:55:46 +0900 Subject: [PATCH 08/16] =?UTF-8?q?[FEATURE]=20=EC=97=AC=ED=96=89=20?= =?UTF-8?q?=EC=9E=A5=EC=86=8C=20=EA=B5=AC=EB=B3=84=20=EC=9C=84=ED=95=9C=20?= =?UTF-8?q?Enum=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/hyu/erica/capstone/domain/enums/PlaceType.java | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/main/java/hyu/erica/capstone/domain/enums/PlaceType.java diff --git a/src/main/java/hyu/erica/capstone/domain/enums/PlaceType.java b/src/main/java/hyu/erica/capstone/domain/enums/PlaceType.java new file mode 100644 index 0000000..2d16be3 --- /dev/null +++ b/src/main/java/hyu/erica/capstone/domain/enums/PlaceType.java @@ -0,0 +1,5 @@ +package hyu.erica.capstone.domain.enums; + +public enum PlaceType { + ATTRACTION, RESTAURANT +} From 69790c412c50e1a0a45c01f01257780eaef4e817 Mon Sep 17 00:00:00 2001 From: msk226 Date: Mon, 24 Mar 2025 13:56:03 +0900 Subject: [PATCH 09/16] =?UTF-8?q?[FEATURE]=20=EC=97=AC=ED=96=89=20?= =?UTF-8?q?=EC=9D=BC=EC=A0=95=20=EC=9D=91=EB=8B=B5=20=EC=9C=84=ED=95=9C=20?= =?UTF-8?q?DTO=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tripPlan/TripPlanQueryService.java | 12 +- .../impl/TripPlanQueryServiceImpl.java | 13 +-- .../response/TripPlanResultResponseDTO.java | 109 ++++++++++++++++++ 3 files changed, 121 insertions(+), 13 deletions(-) create mode 100644 src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/TripPlanResultResponseDTO.java diff --git a/src/main/java/hyu/erica/capstone/service/tripPlan/TripPlanQueryService.java b/src/main/java/hyu/erica/capstone/service/tripPlan/TripPlanQueryService.java index 5f83505..27a4961 100644 --- a/src/main/java/hyu/erica/capstone/service/tripPlan/TripPlanQueryService.java +++ b/src/main/java/hyu/erica/capstone/service/tripPlan/TripPlanQueryService.java @@ -1,11 +1,11 @@ package hyu.erica.capstone.service.tripPlan; -import hyu.erica.capstone.web.dto.tripPlan.response.AttractionDetailResponseDTO; -import hyu.erica.capstone.web.dto.tripPlan.response.AttractionListResponseDTO; -import hyu.erica.capstone.web.dto.tripPlan.response.AttractionSearchResponseDTO; -import hyu.erica.capstone.web.dto.tripPlan.response.RestaurantDetailResponseDTO; -import hyu.erica.capstone.web.dto.tripPlan.response.RestaurantListResponseDTO; -import hyu.erica.capstone.web.dto.tripPlan.response.RestaurantSearchResponseDTO; +import hyu.erica.capstone.web.dto.tripPlan.response.attraction.AttractionDetailResponseDTO; +import hyu.erica.capstone.web.dto.tripPlan.response.attraction.AttractionListResponseDTO; +import hyu.erica.capstone.web.dto.tripPlan.response.attraction.AttractionSearchResponseDTO; +import hyu.erica.capstone.web.dto.tripPlan.response.restaurant.RestaurantDetailResponseDTO; +import hyu.erica.capstone.web.dto.tripPlan.response.restaurant.RestaurantListResponseDTO; +import hyu.erica.capstone.web.dto.tripPlan.response.restaurant.RestaurantSearchResponseDTO; public interface TripPlanQueryService { diff --git a/src/main/java/hyu/erica/capstone/service/tripPlan/impl/TripPlanQueryServiceImpl.java b/src/main/java/hyu/erica/capstone/service/tripPlan/impl/TripPlanQueryServiceImpl.java index 9973baf..e3462cf 100644 --- a/src/main/java/hyu/erica/capstone/service/tripPlan/impl/TripPlanQueryServiceImpl.java +++ b/src/main/java/hyu/erica/capstone/service/tripPlan/impl/TripPlanQueryServiceImpl.java @@ -4,7 +4,6 @@ import hyu.erica.capstone.api.exception.GeneralException; import hyu.erica.capstone.domain.Attraction; import hyu.erica.capstone.domain.Restaurant; -import hyu.erica.capstone.domain.TripPlan; import hyu.erica.capstone.domain.mapping.PreferAttraction; import hyu.erica.capstone.domain.mapping.PreferRestaurant; import hyu.erica.capstone.repository.AttractionRepository; @@ -14,12 +13,12 @@ import hyu.erica.capstone.repository.TripPlanRepository; import hyu.erica.capstone.repository.UserRepository; import hyu.erica.capstone.service.tripPlan.TripPlanQueryService; -import hyu.erica.capstone.web.dto.tripPlan.response.AttractionDetailResponseDTO; -import hyu.erica.capstone.web.dto.tripPlan.response.AttractionListResponseDTO; -import hyu.erica.capstone.web.dto.tripPlan.response.AttractionSearchResponseDTO; -import hyu.erica.capstone.web.dto.tripPlan.response.RestaurantDetailResponseDTO; -import hyu.erica.capstone.web.dto.tripPlan.response.RestaurantListResponseDTO; -import hyu.erica.capstone.web.dto.tripPlan.response.RestaurantSearchResponseDTO; +import hyu.erica.capstone.web.dto.tripPlan.response.attraction.AttractionDetailResponseDTO; +import hyu.erica.capstone.web.dto.tripPlan.response.attraction.AttractionListResponseDTO; +import hyu.erica.capstone.web.dto.tripPlan.response.attraction.AttractionSearchResponseDTO; +import hyu.erica.capstone.web.dto.tripPlan.response.restaurant.RestaurantDetailResponseDTO; +import hyu.erica.capstone.web.dto.tripPlan.response.restaurant.RestaurantListResponseDTO; +import hyu.erica.capstone.web.dto.tripPlan.response.restaurant.RestaurantSearchResponseDTO; import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; diff --git a/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/TripPlanResultResponseDTO.java b/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/TripPlanResultResponseDTO.java new file mode 100644 index 0000000..b24e36f --- /dev/null +++ b/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/TripPlanResultResponseDTO.java @@ -0,0 +1,109 @@ +package hyu.erica.capstone.web.dto.tripPlan.response; + +import hyu.erica.capstone.domain.Attraction; +import hyu.erica.capstone.domain.Restaurant; +import hyu.erica.capstone.domain.TripPlan; +import hyu.erica.capstone.domain.TripScheduleItem; +import hyu.erica.capstone.domain.enums.PlaceType; + +import java.time.LocalDate; +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public record TripPlanResultResponseDTO( + String title, + String description, + String profileImage, + LocalDate startDate, + LocalDate endDate, + List days +) { + + public static TripPlanResultResponseDTO of(TripPlan tripPlan, List scheduleItems) { + // 일자별로 그룹화 (dayNumber 기준) + Map> groupedByDay = scheduleItems.stream() + .collect(Collectors.groupingBy(TripScheduleItem::getDayNumber)); + + List days = groupedByDay.entrySet().stream() + .map(entry -> { + int dayNumber = entry.getKey(); + List items = entry.getValue().stream() + .sorted(Comparator.comparingInt(TripScheduleItem::getOrderInDay)) // 정렬 + .toList(); + + // startDate + (dayNumber - 1)로 실제 날짜 계산 + LocalDate date = tripPlan.getStartDate().plusDays(dayNumber - 1); + return TripPlanDayDTO.of(dayNumber, date, items); + }) + .sorted(Comparator.comparingInt(TripPlanDayDTO::dayNumber)) // day 순으로 정렬 + .toList(); + + return new TripPlanResultResponseDTO( + tripPlan.getTitle(), + tripPlan.getDescription(), + tripPlan.getProfileImage(), + tripPlan.getStartDate(), + tripPlan.getEndDate(), + days + ); + } + + public record TripPlanDayDTO( + int dayNumber, + LocalDate date, + List scheduleItems + ) { + public static TripPlanDayDTO of(int dayNumber, LocalDate date, List items) { + List dtos = items.stream() + .map(TripScheduleItemDTO::of) + .toList(); + return new TripPlanDayDTO(dayNumber, date, dtos); + } + } + + public record TripScheduleItemDTO( + Long itemId, + int order, + PlaceType placeType, // "ATTRACTION" or "RESTAURANT" + Long placeId, + String name, + String imageUrl, + String memo + ) { + public static TripScheduleItemDTO of(TripScheduleItem tripScheduleItem) { + PlaceType placeType = tripScheduleItem.getPlaceType(); + Long placeId; + String name; + String imageUrl; + + switch (placeType) { + case ATTRACTION -> { + Attraction attraction = tripScheduleItem.getAttraction(); + placeId = attraction.getContentId(); + name = attraction.getContentName(); + imageUrl = attraction.getImageUrl(); + } + case RESTAURANT -> { + Restaurant restaurant = tripScheduleItem.getRestaurant(); + placeId = restaurant.getId(); + name = restaurant.getRestaurantName(); + imageUrl = restaurant.getHomepageUrl(); // 또는 대표 이미지 필드로 교체 가능 + } + default -> throw new IllegalArgumentException("지원하지 않는 장소 타입입니다."); + } + + return new TripScheduleItemDTO( + tripScheduleItem.getId(), + tripScheduleItem.getOrderInDay(), + placeType, + placeId, + name, + imageUrl, + tripScheduleItem.getMemo() + ); + } + } + +} From eda2cbe037f69462a7289f4b3edf44f58f5791e2 Mon Sep 17 00:00:00 2001 From: msk226 Date: Mon, 24 Mar 2025 13:59:59 +0900 Subject: [PATCH 10/16] =?UTF-8?q?[FEATURE]=20TripScheduleItem=EA=B3=BC=20T?= =?UTF-8?q?ripPlan=20=EC=97=B0=EA=B4=80=20=EA=B4=80=EA=B3=84=20=EB=A7=A4?= =?UTF-8?q?=ED=95=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/hyu/erica/capstone/domain/TripPlan.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/hyu/erica/capstone/domain/TripPlan.java b/src/main/java/hyu/erica/capstone/domain/TripPlan.java index fd5a7d1..c41bdac 100644 --- a/src/main/java/hyu/erica/capstone/domain/TripPlan.java +++ b/src/main/java/hyu/erica/capstone/domain/TripPlan.java @@ -55,10 +55,14 @@ public class TripPlan { @JoinColumn(name = "user_id") private User user; - @OneToMany(mappedBy = "tripPlan", cascade = CascadeType.ALL) + @OneToMany(mappedBy = "tripPlan", cascade = CascadeType.ALL, orphanRemoval = true) + private List tripScheduleItems; + + + @OneToMany(mappedBy = "tripPlan", cascade = CascadeType.ALL, orphanRemoval = true) private List preferAttractions; - @OneToMany(mappedBy = "tripPlan", cascade = CascadeType.ALL) + @OneToMany(mappedBy = "tripPlan", cascade = CascadeType.ALL, orphanRemoval = true) private List preferRestaurants; From 42d39363fc220b46306169208ac35a3dcb432b9b Mon Sep 17 00:00:00 2001 From: msk226 Date: Mon, 24 Mar 2025 14:24:00 +0900 Subject: [PATCH 11/16] =?UTF-8?q?[FEATURE]=20=EC=B5=9C=EC=A2=85=20?= =?UTF-8?q?=EC=84=A0=ED=83=9D=20=EC=8B=9C,=20=EC=97=AC=ED=96=89=20?= =?UTF-8?q?=EC=9D=BC=EC=A0=95=20=EC=A0=9C=EC=9E=91=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PreferAttractionRepository.java | 2 +- .../PreferRestaurantRepository.java | 1 + .../TripScheduleItemRepository.java | 9 ++ .../impl/TripPlanCommandServiceImpl.java | 98 ++++++++++++++++++- 4 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 src/main/java/hyu/erica/capstone/repository/TripScheduleItemRepository.java diff --git a/src/main/java/hyu/erica/capstone/repository/PreferAttractionRepository.java b/src/main/java/hyu/erica/capstone/repository/PreferAttractionRepository.java index 75e3e29..1a00e8b 100644 --- a/src/main/java/hyu/erica/capstone/repository/PreferAttractionRepository.java +++ b/src/main/java/hyu/erica/capstone/repository/PreferAttractionRepository.java @@ -2,7 +2,6 @@ import hyu.erica.capstone.domain.mapping.PreferAttraction; import java.util.List; -import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @@ -10,5 +9,6 @@ public interface PreferAttractionRepository extends JpaRepository { List findAllByTripPlanId(Long tripPlanId); + List findByTripPlanIdAndIsPreferTrue(Long tripPlanId); boolean existsByAttraction_ContentIdAndUserId(Long attractionId, Long userId); } diff --git a/src/main/java/hyu/erica/capstone/repository/PreferRestaurantRepository.java b/src/main/java/hyu/erica/capstone/repository/PreferRestaurantRepository.java index 098c306..dd441ec 100644 --- a/src/main/java/hyu/erica/capstone/repository/PreferRestaurantRepository.java +++ b/src/main/java/hyu/erica/capstone/repository/PreferRestaurantRepository.java @@ -8,5 +8,6 @@ @Repository public interface PreferRestaurantRepository extends JpaRepository { List findAllByTripPlanId(Long tripPlanId); + List findByTripPlanIdAndIsPreferTrue(Long tripPlanId); boolean existsByRestaurantIdAndUserId(Long restaurantId, Long userId); } diff --git a/src/main/java/hyu/erica/capstone/repository/TripScheduleItemRepository.java b/src/main/java/hyu/erica/capstone/repository/TripScheduleItemRepository.java new file mode 100644 index 0000000..5b03ceb --- /dev/null +++ b/src/main/java/hyu/erica/capstone/repository/TripScheduleItemRepository.java @@ -0,0 +1,9 @@ +package hyu.erica.capstone.repository; + +import hyu.erica.capstone.domain.TripScheduleItem; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface TripScheduleItemRepository extends JpaRepository { +} diff --git a/src/main/java/hyu/erica/capstone/service/tripPlan/impl/TripPlanCommandServiceImpl.java b/src/main/java/hyu/erica/capstone/service/tripPlan/impl/TripPlanCommandServiceImpl.java index 4cf28be..60375aa 100644 --- a/src/main/java/hyu/erica/capstone/service/tripPlan/impl/TripPlanCommandServiceImpl.java +++ b/src/main/java/hyu/erica/capstone/service/tripPlan/impl/TripPlanCommandServiceImpl.java @@ -1,15 +1,27 @@ package hyu.erica.capstone.service.tripPlan.impl; +import static java.time.temporal.ChronoUnit.DAYS; + +import hyu.erica.capstone.api.code.status.ErrorStatus; +import hyu.erica.capstone.api.exception.GeneralException; +import hyu.erica.capstone.domain.Attraction; +import hyu.erica.capstone.domain.Restaurant; +import hyu.erica.capstone.domain.TripPlan; +import hyu.erica.capstone.domain.TripScheduleItem; +import hyu.erica.capstone.domain.enums.PlaceType; import hyu.erica.capstone.domain.mapping.PreferAttraction; import hyu.erica.capstone.domain.mapping.PreferRestaurant; import hyu.erica.capstone.repository.PreferAttractionRepository; import hyu.erica.capstone.repository.PreferRestaurantRepository; import hyu.erica.capstone.repository.TripPlanRepository; -import hyu.erica.capstone.repository.UserRepository; +import hyu.erica.capstone.repository.TripScheduleItemRepository; import hyu.erica.capstone.service.tripPlan.TripPlanCommandService; import hyu.erica.capstone.web.dto.trip.request.SaveAttractionRequestDTO; import hyu.erica.capstone.web.dto.trip.request.SaveRestaurantRequestDTO; +import java.util.ArrayList; +import java.util.Comparator; import java.util.List; +import java.util.Random; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -21,6 +33,7 @@ public class TripPlanCommandServiceImpl implements TripPlanCommandService { private final PreferAttractionRepository preferAttractionRepository; private final PreferRestaurantRepository preferRestaurantRepository; + private final TripScheduleItemRepository tripScheduleItemRepository; private final TripPlanRepository tripPlanRepository; @Override @@ -46,6 +59,89 @@ public Long confirmRestaurantRecommendation(Long tripPlanId, SaveRestaurantReque } } + preferRestaurantRepository.flush(); + + createTripPlanFinal(tripPlanId); return tripPlanId; } + + private void createTripPlanFinal(Long tripPlanId) { + TripPlan tripPlan = tripPlanRepository.findById(tripPlanId) + .orElseThrow(() -> new GeneralException(ErrorStatus._TRIP_PLAN_NOT_FOUND)); + + List attractions = preferAttractionRepository.findByTripPlanIdAndIsPreferTrue(tripPlanId); + List restaurants = preferRestaurantRepository.findByTripPlanIdAndIsPreferTrue(tripPlanId); + + int totalDays = (int) DAYS.between(tripPlan.getStartDate(), tripPlan.getEndDate()) + 1; + + Random random = new Random(); + List scheduleItems = new ArrayList<>(); + + for (int day = 1; day <= totalDays; day++) { + // 랜덤 피벗 선택 + Attraction pivot = getRandom(attractions, random).getAttraction(); + Restaurant restaurantPivot = getRandom(restaurants, random).getRestaurant(); + + List sortedAttractions = attractions.stream() + .map(PreferAttraction::getAttraction) + .sorted(Comparator.comparingDouble(a -> + distance(pivot.getLatitude(), pivot.getLongitude(), a.getLatitude(), a.getLongitude()))) + .limit(3) + .toList(); + + List sortedRestaurants = restaurants.stream() + .map(PreferRestaurant::getRestaurant) + .sorted(Comparator.comparingDouble(r -> + distance(restaurantPivot.getLatitude(), restaurantPivot.getLongitude(), + r.getLatitude(), r.getLongitude()))) + .limit(3) + .toList(); + + int order = 1; + for (int i = 0; i < 3; i++) { + // 여행지 먼저 + if (i < sortedAttractions.size()) { + scheduleItems.add(TripScheduleItem.builder() + .tripPlan(tripPlan) + .dayNumber(day) + .orderInDay(order++) + .placeType(PlaceType.ATTRACTION) + .attraction(sortedAttractions.get(i)) + .build()); + } + + // 식당 다음 + if (i < sortedRestaurants.size()) { + scheduleItems.add(TripScheduleItem.builder() + .tripPlan(tripPlan) + .dayNumber(day) + .orderInDay(order++) + .placeType(PlaceType.RESTAURANT) + .restaurant(sortedRestaurants.get(i)) + .build()); + } + } + } + + + tripScheduleItemRepository.saveAll(scheduleItems); + } + + private double distance(double lat1, double lon1, double lat2, double lon2) { + double R = 6371; // Earth radius in km + double dLat = Math.toRadians(lat2 - lat1); + double dLon = Math.toRadians(lon2 - lon1); + double a = Math.sin(dLat/2) * Math.sin(dLat/2) + + Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) * + Math.sin(dLon/2) * Math.sin(dLon/2); + double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); + return R * c; // in kilometers + } + + + private T getRandom(List list, Random random) { + return list.get(random.nextInt(list.size())); + } + + } From 3c9be3c5d4cc481a7a89b5372b6df5f79d1aae4f Mon Sep 17 00:00:00 2001 From: msk226 Date: Mon, 24 Mar 2025 14:29:03 +0900 Subject: [PATCH 12/16] =?UTF-8?q?[FEATURE]=20=EC=97=AC=ED=96=89=20?= =?UTF-8?q?=EC=9D=BC=EC=A0=95=20=EC=A1=B0=ED=9A=8C=20API=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TripScheduleItemRepository.java | 2 ++ .../tripPlan/TripPlanQueryService.java | 4 +++ .../impl/TripPlanQueryServiceImpl.java | 15 ++++++++++ .../web/controller/PlanController.java | 28 +++++++++++++++---- 4 files changed, 44 insertions(+), 5 deletions(-) diff --git a/src/main/java/hyu/erica/capstone/repository/TripScheduleItemRepository.java b/src/main/java/hyu/erica/capstone/repository/TripScheduleItemRepository.java index 5b03ceb..d2c1851 100644 --- a/src/main/java/hyu/erica/capstone/repository/TripScheduleItemRepository.java +++ b/src/main/java/hyu/erica/capstone/repository/TripScheduleItemRepository.java @@ -1,9 +1,11 @@ package hyu.erica.capstone.repository; import hyu.erica.capstone.domain.TripScheduleItem; +import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository public interface TripScheduleItemRepository extends JpaRepository { + List findAllByTripPlanId(Long tripPlanId); } diff --git a/src/main/java/hyu/erica/capstone/service/tripPlan/TripPlanQueryService.java b/src/main/java/hyu/erica/capstone/service/tripPlan/TripPlanQueryService.java index 27a4961..b42cdc7 100644 --- a/src/main/java/hyu/erica/capstone/service/tripPlan/TripPlanQueryService.java +++ b/src/main/java/hyu/erica/capstone/service/tripPlan/TripPlanQueryService.java @@ -1,5 +1,6 @@ package hyu.erica.capstone.service.tripPlan; +import hyu.erica.capstone.web.dto.tripPlan.response.TripPlanResultResponseDTO; import hyu.erica.capstone.web.dto.tripPlan.response.attraction.AttractionDetailResponseDTO; import hyu.erica.capstone.web.dto.tripPlan.response.attraction.AttractionListResponseDTO; import hyu.erica.capstone.web.dto.tripPlan.response.attraction.AttractionSearchResponseDTO; @@ -9,6 +10,9 @@ public interface TripPlanQueryService { + // 여행 일정 조회 + TripPlanResultResponseDTO getTripPlan(Long tripPlanId); + // 추천 여행지 리스트 조회 AttractionListResponseDTO getRecommendAttractions(Long tripPlanId); diff --git a/src/main/java/hyu/erica/capstone/service/tripPlan/impl/TripPlanQueryServiceImpl.java b/src/main/java/hyu/erica/capstone/service/tripPlan/impl/TripPlanQueryServiceImpl.java index e3462cf..b21339e 100644 --- a/src/main/java/hyu/erica/capstone/service/tripPlan/impl/TripPlanQueryServiceImpl.java +++ b/src/main/java/hyu/erica/capstone/service/tripPlan/impl/TripPlanQueryServiceImpl.java @@ -4,6 +4,8 @@ import hyu.erica.capstone.api.exception.GeneralException; import hyu.erica.capstone.domain.Attraction; import hyu.erica.capstone.domain.Restaurant; +import hyu.erica.capstone.domain.TripPlan; +import hyu.erica.capstone.domain.TripScheduleItem; import hyu.erica.capstone.domain.mapping.PreferAttraction; import hyu.erica.capstone.domain.mapping.PreferRestaurant; import hyu.erica.capstone.repository.AttractionRepository; @@ -11,8 +13,10 @@ import hyu.erica.capstone.repository.PreferRestaurantRepository; import hyu.erica.capstone.repository.RestaurantRepository; import hyu.erica.capstone.repository.TripPlanRepository; +import hyu.erica.capstone.repository.TripScheduleItemRepository; import hyu.erica.capstone.repository.UserRepository; import hyu.erica.capstone.service.tripPlan.TripPlanQueryService; +import hyu.erica.capstone.web.dto.tripPlan.response.TripPlanResultResponseDTO; import hyu.erica.capstone.web.dto.tripPlan.response.attraction.AttractionDetailResponseDTO; import hyu.erica.capstone.web.dto.tripPlan.response.attraction.AttractionListResponseDTO; import hyu.erica.capstone.web.dto.tripPlan.response.attraction.AttractionSearchResponseDTO; @@ -34,8 +38,19 @@ public class TripPlanQueryServiceImpl implements TripPlanQueryService { private final RestaurantRepository restaurantRepository; private final PreferRestaurantRepository preferRestaurantRepository; private final PreferAttractionRepository preferAttractionRepository; + private final TripScheduleItemRepository tripScheduleItemRepository; private final UserRepository userRepository; + @Override + public TripPlanResultResponseDTO getTripPlan(Long tripPlanId) { + TripPlan tripPlan = tripPlanRepository.findById(tripPlanId) + .orElseThrow(() -> new GeneralException(ErrorStatus._TRIP_PLAN_NOT_FOUND)); + + List tripScheduleItems = tripScheduleItemRepository.findAllByTripPlanId(tripPlanId); + + return TripPlanResultResponseDTO.of(tripPlan, tripScheduleItems); + } + @Override public AttractionListResponseDTO getRecommendAttractions(Long tripPlanId) { if (!tripPlanRepository.existsById(tripPlanId)) diff --git a/src/main/java/hyu/erica/capstone/web/controller/PlanController.java b/src/main/java/hyu/erica/capstone/web/controller/PlanController.java index 8b0b301..3103141 100644 --- a/src/main/java/hyu/erica/capstone/web/controller/PlanController.java +++ b/src/main/java/hyu/erica/capstone/web/controller/PlanController.java @@ -2,10 +2,15 @@ import hyu.erica.capstone.api.ApiResponse; +import hyu.erica.capstone.api.code.status.SuccessStatus; +import hyu.erica.capstone.service.tripPlan.TripPlanQueryService; +import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -14,14 +19,28 @@ @Tag(name = "[개발 전] 여행 계획", description = "여행 계획 관련 API") @CrossOrigin @RestController -@RequestMapping("/api/plans") +@RequestMapping("/api/trip-plans") +@RequiredArgsConstructor public class PlanController { + private final TripPlanQueryService tripPlanQueryService; + // 일정 제공 - @GetMapping("/{planId}") - public ApiResponse getPlan() { + @Operation(summary = "일정 제공", description = """ + ### 일정 제공 API + 일정 확인을 위한 API입니다. 조회 하려는 여행 계획 ID를 Path Variable로 입력해주세요. + + ### Path Variables + - tripPlanId: 여행 계획 ID + + ### Response + - tripPlanId: 여행 계획 ID + + """) + @GetMapping("/{tripPlanId}") + public ApiResponse getPlan(@PathVariable Long tripPlanId) { // 일정 제공 - return null; + return ApiResponse.onSuccess(SuccessStatus._OK, tripPlanQueryService.getTripPlan(tripPlanId)); } // Result 화면 위한 API @@ -45,7 +64,6 @@ public ApiResponse editPlan() { return null; } - // 일정 편집 (삭제) @DeleteMapping() public ApiResponse deletePlan() { From 5fb5cf5d96841dfab916e14ffec8802467a3c246 Mon Sep 17 00:00:00 2001 From: msk226 Date: Mon, 24 Mar 2025 14:34:48 +0900 Subject: [PATCH 13/16] =?UTF-8?q?[FEATURE]=20=EC=97=AC=ED=96=89=20?= =?UTF-8?q?=EC=9D=BC=EC=A0=95=20=EC=83=9D=EC=84=B1=20=EB=82=B4=EB=B6=80=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EB=B3=80=EA=B2=BD=20->=20=EA=B1=B0?= =?UTF-8?q?=EB=A6=AC=20=EC=88=9C=20=EC=A0=95=EB=A0=AC=EC=9D=80=20=EC=B6=94?= =?UTF-8?q?=ED=9B=84=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/TripPlanCommandServiceImpl.java | 114 +++++++++--------- 1 file changed, 55 insertions(+), 59 deletions(-) diff --git a/src/main/java/hyu/erica/capstone/service/tripPlan/impl/TripPlanCommandServiceImpl.java b/src/main/java/hyu/erica/capstone/service/tripPlan/impl/TripPlanCommandServiceImpl.java index 60375aa..1876b48 100644 --- a/src/main/java/hyu/erica/capstone/service/tripPlan/impl/TripPlanCommandServiceImpl.java +++ b/src/main/java/hyu/erica/capstone/service/tripPlan/impl/TripPlanCommandServiceImpl.java @@ -19,9 +19,11 @@ import hyu.erica.capstone.web.dto.trip.request.SaveAttractionRequestDTO; import hyu.erica.capstone.web.dto.trip.request.SaveRestaurantRequestDTO; import java.util.ArrayList; +import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Random; +import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -64,84 +66,78 @@ public Long confirmRestaurantRecommendation(Long tripPlanId, SaveRestaurantReque createTripPlanFinal(tripPlanId); return tripPlanId; } - private void createTripPlanFinal(Long tripPlanId) { TripPlan tripPlan = tripPlanRepository.findById(tripPlanId) .orElseThrow(() -> new GeneralException(ErrorStatus._TRIP_PLAN_NOT_FOUND)); - List attractions = preferAttractionRepository.findByTripPlanIdAndIsPreferTrue(tripPlanId); - List restaurants = preferRestaurantRepository.findByTripPlanIdAndIsPreferTrue(tripPlanId); + List allAttractions = preferAttractionRepository.findByTripPlanIdAndIsPreferTrue(tripPlanId) + .stream().map(PreferAttraction::getAttraction).collect(Collectors.toList()); + + List allRestaurants = preferRestaurantRepository.findByTripPlanIdAndIsPreferTrue(tripPlanId) + .stream().map(PreferRestaurant::getRestaurant).collect(Collectors.toList()); int totalDays = (int) DAYS.between(tripPlan.getStartDate(), tripPlan.getEndDate()) + 1; - Random random = new Random(); - List scheduleItems = new ArrayList<>(); + // 섞기 + Collections.shuffle(allAttractions); + Collections.shuffle(allRestaurants); - for (int day = 1; day <= totalDays; day++) { - // 랜덤 피벗 선택 - Attraction pivot = getRandom(attractions, random).getAttraction(); - Restaurant restaurantPivot = getRandom(restaurants, random).getRestaurant(); - - List sortedAttractions = attractions.stream() - .map(PreferAttraction::getAttraction) - .sorted(Comparator.comparingDouble(a -> - distance(pivot.getLatitude(), pivot.getLongitude(), a.getLatitude(), a.getLongitude()))) - .limit(3) - .toList(); - - List sortedRestaurants = restaurants.stream() - .map(PreferRestaurant::getRestaurant) - .sorted(Comparator.comparingDouble(r -> - distance(restaurantPivot.getLatitude(), restaurantPivot.getLongitude(), - r.getLatitude(), r.getLongitude()))) - .limit(3) - .toList(); + // 필요한 개수만큼만 사용 (초과할 경우 대비) + int maxAttractions = Math.min(totalDays * 2, allAttractions.size()); + int maxRestaurants = Math.min(totalDays * 2, allRestaurants.size()); + + List usableAttractions = allAttractions.subList(0, maxAttractions); + List usableRestaurants = allRestaurants.subList(0, maxRestaurants); + + List scheduleItems = new ArrayList<>(); + for (int day = 0; day < totalDays; day++) { int order = 1; - for (int i = 0; i < 3; i++) { - // 여행지 먼저 - if (i < sortedAttractions.size()) { - scheduleItems.add(TripScheduleItem.builder() - .tripPlan(tripPlan) - .dayNumber(day) - .orderInDay(order++) - .placeType(PlaceType.ATTRACTION) - .attraction(sortedAttractions.get(i)) - .build()); - } - - // 식당 다음 - if (i < sortedRestaurants.size()) { - scheduleItems.add(TripScheduleItem.builder() - .tripPlan(tripPlan) - .dayNumber(day) - .orderInDay(order++) - .placeType(PlaceType.RESTAURANT) - .restaurant(sortedRestaurants.get(i)) - .build()); - } + + // 각 날짜마다 2개씩 할당 + if (day * 2 + 1 < usableAttractions.size()) { + scheduleItems.add(createScheduleItem(tripPlan, day + 1, order++, PlaceType.ATTRACTION, usableAttractions.get(day * 2))); + scheduleItems.add(createScheduleItem(tripPlan, day + 1, order++, PlaceType.RESTAURANT, usableRestaurants.get(day * 2))); + scheduleItems.add(createScheduleItem(tripPlan, day + 1, order++, PlaceType.ATTRACTION, usableAttractions.get(day * 2 + 1))); + scheduleItems.add(createScheduleItem(tripPlan, day + 1, order++, PlaceType.RESTAURANT, usableRestaurants.get(day * 2 + 1))); } } - tripScheduleItemRepository.saveAll(scheduleItems); } - private double distance(double lat1, double lon1, double lat2, double lon2) { - double R = 6371; // Earth radius in km - double dLat = Math.toRadians(lat2 - lat1); - double dLon = Math.toRadians(lon2 - lon1); - double a = Math.sin(dLat/2) * Math.sin(dLat/2) + - Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) * - Math.sin(dLon/2) * Math.sin(dLon/2); - double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); - return R * c; // in kilometers + private TripScheduleItem createScheduleItem(TripPlan tripPlan, int day, int order, PlaceType type, Object place) { + TripScheduleItem.TripScheduleItemBuilder builder = TripScheduleItem.builder() + .tripPlan(tripPlan) + .dayNumber(day) + .orderInDay(order) + .placeType(type); + + if (type == PlaceType.ATTRACTION) { + builder.attraction((Attraction) place); + } else { + builder.restaurant((Restaurant) place); + } + + return builder.build(); } - private T getRandom(List list, Random random) { - return list.get(random.nextInt(list.size())); - } +// private double distance(double lat1, double lon1, double lat2, double lon2) { +// double R = 6371; // Earth radius in km +// double dLat = Math.toRadians(lat2 - lat1); +// double dLon = Math.toRadians(lon2 - lon1); +// double a = Math.sin(dLat/2) * Math.sin(dLat/2) + +// Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) * +// Math.sin(dLon/2) * Math.sin(dLon/2); +// double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); +// return R * c; // in kilometers +// } +// +// +// private T getRandom(List list, Random random) { +// return list.get(random.nextInt(list.size())); +// } } From 9002f4d2256923adcdf487e8caac12aa51a1f34f Mon Sep 17 00:00:00 2001 From: msk226 Date: Mon, 24 Mar 2025 14:36:50 +0900 Subject: [PATCH 14/16] =?UTF-8?q?[FEATURE]=20=EC=97=AC=ED=96=89=20?= =?UTF-8?q?=EC=9D=BC=EC=A0=95=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C,=20?= =?UTF-8?q?=EC=A2=8C=ED=91=9C=20=EA=B0=92=20=ED=95=A8=EA=BB=98=20=EC=9D=91?= =?UTF-8?q?=EB=8B=B5=20=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tripPlan/response/TripPlanResultResponseDTO.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/TripPlanResultResponseDTO.java b/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/TripPlanResultResponseDTO.java index b24e36f..7751146 100644 --- a/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/TripPlanResultResponseDTO.java +++ b/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/TripPlanResultResponseDTO.java @@ -68,6 +68,8 @@ public record TripScheduleItemDTO( int order, PlaceType placeType, // "ATTRACTION" or "RESTAURANT" Long placeId, + Double latitude, + Double longitude, String name, String imageUrl, String memo @@ -77,6 +79,8 @@ public static TripScheduleItemDTO of(TripScheduleItem tripScheduleItem) { Long placeId; String name; String imageUrl; + Double latitude; + Double longitude; switch (placeType) { case ATTRACTION -> { @@ -84,12 +88,16 @@ public static TripScheduleItemDTO of(TripScheduleItem tripScheduleItem) { placeId = attraction.getContentId(); name = attraction.getContentName(); imageUrl = attraction.getImageUrl(); + latitude = attraction.getLatitude(); + longitude = attraction.getLongitude(); } case RESTAURANT -> { Restaurant restaurant = tripScheduleItem.getRestaurant(); placeId = restaurant.getId(); name = restaurant.getRestaurantName(); - imageUrl = restaurant.getHomepageUrl(); // 또는 대표 이미지 필드로 교체 가능 + imageUrl = restaurant.getHomepageUrl(); // 임시 처리 + latitude = restaurant.getLatitude(); + longitude = restaurant.getLongitude(); } default -> throw new IllegalArgumentException("지원하지 않는 장소 타입입니다."); } @@ -99,6 +107,8 @@ public static TripScheduleItemDTO of(TripScheduleItem tripScheduleItem) { tripScheduleItem.getOrderInDay(), placeType, placeId, + latitude, + longitude, name, imageUrl, tripScheduleItem.getMemo() From 28db5c6f363fde4a735869d06c512ac7219c98d2 Mon Sep 17 00:00:00 2001 From: msk226 Date: Mon, 24 Mar 2025 14:40:17 +0900 Subject: [PATCH 15/16] =?UTF-8?q?[FEATURE]=20=EB=AF=B8=EC=A7=80=EC=9B=90?= =?UTF-8?q?=20=EC=A7=80=EC=97=AD=20=ED=83=80=EC=9E=85=EC=9D=BC=20=EA=B2=BD?= =?UTF-8?q?=EC=9A=B0,=20=EC=BB=A4=EC=8A=A4=ED=85=80=20=EC=97=90=EB=9F=AC?= =?UTF-8?q?=20=EB=8D=98=EC=A7=80=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/hyu/erica/capstone/api/code/status/ErrorStatus.java | 1 + .../web/dto/tripPlan/response/TripPlanResultResponseDTO.java | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/hyu/erica/capstone/api/code/status/ErrorStatus.java b/src/main/java/hyu/erica/capstone/api/code/status/ErrorStatus.java index ed1e31b..0d66b78 100644 --- a/src/main/java/hyu/erica/capstone/api/code/status/ErrorStatus.java +++ b/src/main/java/hyu/erica/capstone/api/code/status/ErrorStatus.java @@ -28,6 +28,7 @@ public enum ErrorStatus implements BaseErrorCode { _TERMS_NOT_AGREED(HttpStatus.FORBIDDEN, "COMMON4013", "이용 약관이 동의되지 않았습니다."), _MEMBER_EMAIL_EXIST(HttpStatus.BAD_REQUEST, "COMMON4014", "이미 가입 된 이메일입니다. 다른 로그인 방식을 이용해주세요."), _RSA_ERROR(HttpStatus.BAD_REQUEST, "COMMON4015", "RSA 에러가 발생했습니다."), + _UNSUPPORTED_PLACE_TYPE(HttpStatus.BAD_REQUEST, "PLACE4000", "지원하지 않는 장소 타입입니다."), // 파일 에러 _FILE_INPUT_ERROR(HttpStatus.BAD_REQUEST, "FILE4000", "파일 입력 중 에러가 발생했습니다."), diff --git a/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/TripPlanResultResponseDTO.java b/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/TripPlanResultResponseDTO.java index 7751146..4202003 100644 --- a/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/TripPlanResultResponseDTO.java +++ b/src/main/java/hyu/erica/capstone/web/dto/tripPlan/response/TripPlanResultResponseDTO.java @@ -1,5 +1,7 @@ package hyu.erica.capstone.web.dto.tripPlan.response; +import hyu.erica.capstone.api.code.status.ErrorStatus; +import hyu.erica.capstone.api.exception.GeneralException; import hyu.erica.capstone.domain.Attraction; import hyu.erica.capstone.domain.Restaurant; import hyu.erica.capstone.domain.TripPlan; @@ -99,7 +101,7 @@ public static TripScheduleItemDTO of(TripScheduleItem tripScheduleItem) { latitude = restaurant.getLatitude(); longitude = restaurant.getLongitude(); } - default -> throw new IllegalArgumentException("지원하지 않는 장소 타입입니다."); + default -> throw new GeneralException(ErrorStatus._UNSUPPORTED_PLACE_TYPE); } return new TripScheduleItemDTO( From 3dc27e1b9e0cf23c274f7f34bb93df6f19359f64 Mon Sep 17 00:00:00 2001 From: msk226 Date: Mon, 24 Mar 2025 15:01:22 +0900 Subject: [PATCH 16/16] =?UTF-8?q?[FEATURE]=20=EC=B6=94=EC=B2=9C=20?= =?UTF-8?q?=EC=96=B4=ED=8A=B8=EB=9E=99=EC=85=98=20=EC=A0=80=EC=9E=A5=20?= =?UTF-8?q?=EC=8B=9C,=20isPrefer=20true=EB=A1=9C=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../erica/capstone/service/async/StyleBackgroundTaskService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/hyu/erica/capstone/service/async/StyleBackgroundTaskService.java b/src/main/java/hyu/erica/capstone/service/async/StyleBackgroundTaskService.java index 5e78c1a..7069b0d 100644 --- a/src/main/java/hyu/erica/capstone/service/async/StyleBackgroundTaskService.java +++ b/src/main/java/hyu/erica/capstone/service/async/StyleBackgroundTaskService.java @@ -82,6 +82,7 @@ public void handleTripPlanDetails(Long tripPlanId, Style style, User user) { preferAttractionRepository.save(PreferAttraction.builder() .attraction(attraction) .user(managedUser) + .isPrefer(true) .tripPlan(tripPlan) .build()); }