From 37476e6d5fd5a0a402221c04b64b9e0aa22e1ab5 Mon Sep 17 00:00:00 2001 From: wooodev <142153611+wooodev@users.noreply.github.com> Date: Wed, 3 Sep 2025 21:25:16 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=83=81=EC=84=B8=20=EC=A0=95=EB=B3=B4?= =?UTF-8?q?=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=B9=B4=ED=85=8C=EA=B3=A0?= =?UTF-8?q?=EB=A6=AC=20=EC=9E=91=EC=97=85=20#135?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../content/controller/ContentController.java | 7 +- .../controller/ContentControllerSwagger.java | 5 +- .../domain/response/PlaceDetailResponse.java | 14 +- .../FestivalInformationRepository.java | 1 + .../LodgeInformationRepository.java | 1 + .../RestaurantInformationRepository.java | 2 + .../SightsInformationRepository.java | 1 + .../content/service/ContentService.java | 174 +++++++++++++++++- 8 files changed, 192 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/swyp/catsgotogedog/content/controller/ContentController.java b/src/main/java/com/swyp/catsgotogedog/content/controller/ContentController.java index c18b80e..4f168e4 100644 --- a/src/main/java/com/swyp/catsgotogedog/content/controller/ContentController.java +++ b/src/main/java/com/swyp/catsgotogedog/content/controller/ContentController.java @@ -61,14 +61,17 @@ public ResponseEntity saveList(@RequestBody List requests) { } @GetMapping("/placedetail") - public ResponseEntity getPlaceDetail(@RequestParam int contentId, @AuthenticationPrincipal String principal){ + public ResponseEntity getPlaceDetail( + @RequestParam int contentId, + @AuthenticationPrincipal String principal, + @RequestParam int contentTypeId){ String userId = null; if (StringUtils.hasText(principal) && NumberUtils.isCreatable(principal)) { userId = principal; } - PlaceDetailResponse placeDetailResponse = contentService.getPlaceDetail(contentId,userId); + PlaceDetailResponse placeDetailResponse = contentService.getPlaceDetail(contentId,userId,contentTypeId); return ResponseEntity.ok(placeDetailResponse); } diff --git a/src/main/java/com/swyp/catsgotogedog/content/controller/ContentControllerSwagger.java b/src/main/java/com/swyp/catsgotogedog/content/controller/ContentControllerSwagger.java index 2483e5c..a4adc10 100644 --- a/src/main/java/com/swyp/catsgotogedog/content/controller/ContentControllerSwagger.java +++ b/src/main/java/com/swyp/catsgotogedog/content/controller/ContentControllerSwagger.java @@ -69,7 +69,10 @@ ResponseEntity getPlaceDetail( @RequestParam int contentId, @Parameter(hidden = true) - @AuthenticationPrincipal String principal + @AuthenticationPrincipal String principal, + + @Parameter(description = "컨텐츠 카테고리 ID", required = true) + @RequestParam int contentTypeId ); @Operation( diff --git a/src/main/java/com/swyp/catsgotogedog/content/domain/response/PlaceDetailResponse.java b/src/main/java/com/swyp/catsgotogedog/content/domain/response/PlaceDetailResponse.java index 5900027..cd05bc8 100644 --- a/src/main/java/com/swyp/catsgotogedog/content/domain/response/PlaceDetailResponse.java +++ b/src/main/java/com/swyp/catsgotogedog/content/domain/response/PlaceDetailResponse.java @@ -1,12 +1,17 @@ package com.swyp.catsgotogedog.content.domain.response; +import com.fasterxml.jackson.annotation.JsonInclude; import com.swyp.catsgotogedog.content.domain.entity.Content; import com.swyp.catsgotogedog.pet.domain.entity.PetGuide; import com.swyp.catsgotogedog.pet.domain.response.PetGuideResponse; import lombok.Builder; import java.util.List; +import java.util.Map; +import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL; + +@JsonInclude(NON_NULL) @Builder public record PlaceDetailResponse( int contentId, @@ -31,7 +36,9 @@ public record PlaceDetailResponse( String overview, List detailImage, PetGuide petGuide, - String restDate) { + String restDate, + Map additionalInformation +) { public static PlaceDetailResponse from( Content c, @@ -42,7 +49,9 @@ public static PlaceDetailResponse from( int totalView, List detailImage, PetGuide petGuide, - String restDate){ + String restDate, + Map additionalInformation + ){ return PlaceDetailResponse.builder() .contentId(c.getContentId()) @@ -68,6 +77,7 @@ public static PlaceDetailResponse from( .detailImage(detailImage) .petGuide(petGuide) .restDate(restDate) + .additionalInformation(additionalInformation) .build(); } } diff --git a/src/main/java/com/swyp/catsgotogedog/content/repository/FestivalInformationRepository.java b/src/main/java/com/swyp/catsgotogedog/content/repository/FestivalInformationRepository.java index d8aa645..40406cd 100644 --- a/src/main/java/com/swyp/catsgotogedog/content/repository/FestivalInformationRepository.java +++ b/src/main/java/com/swyp/catsgotogedog/content/repository/FestivalInformationRepository.java @@ -5,4 +5,5 @@ import com.swyp.catsgotogedog.content.domain.entity.batch.information.FestivalInformation; public interface FestivalInformationRepository extends JpaRepository { + FestivalInformation findByContent_ContentId(int contentId); } diff --git a/src/main/java/com/swyp/catsgotogedog/content/repository/LodgeInformationRepository.java b/src/main/java/com/swyp/catsgotogedog/content/repository/LodgeInformationRepository.java index 920e6aa..4232fab 100644 --- a/src/main/java/com/swyp/catsgotogedog/content/repository/LodgeInformationRepository.java +++ b/src/main/java/com/swyp/catsgotogedog/content/repository/LodgeInformationRepository.java @@ -5,4 +5,5 @@ import com.swyp.catsgotogedog.content.domain.entity.batch.information.LodgeInformation; public interface LodgeInformationRepository extends JpaRepository { + LodgeInformation findByContent_ContentId(int contentId); } diff --git a/src/main/java/com/swyp/catsgotogedog/content/repository/RestaurantInformationRepository.java b/src/main/java/com/swyp/catsgotogedog/content/repository/RestaurantInformationRepository.java index 89ffcbe..0c35fc9 100644 --- a/src/main/java/com/swyp/catsgotogedog/content/repository/RestaurantInformationRepository.java +++ b/src/main/java/com/swyp/catsgotogedog/content/repository/RestaurantInformationRepository.java @@ -19,5 +19,7 @@ public interface RestaurantInformationRepository extends JpaRepository findRestDateByContentIdIn(List contentIds); + + RestaurantInformation findByContent_ContentId(int contentId); } diff --git a/src/main/java/com/swyp/catsgotogedog/content/repository/SightsInformationRepository.java b/src/main/java/com/swyp/catsgotogedog/content/repository/SightsInformationRepository.java index 044f97e..3541358 100644 --- a/src/main/java/com/swyp/catsgotogedog/content/repository/SightsInformationRepository.java +++ b/src/main/java/com/swyp/catsgotogedog/content/repository/SightsInformationRepository.java @@ -19,4 +19,5 @@ public interface SightsInformationRepository extends JpaRepository findRestDateByContentIdIn(List contentIds); + SightsInformation findByContent_ContentId(int contentId); } diff --git a/src/main/java/com/swyp/catsgotogedog/content/service/ContentService.java b/src/main/java/com/swyp/catsgotogedog/content/service/ContentService.java index a385b7b..c27b26d 100644 --- a/src/main/java/com/swyp/catsgotogedog/content/service/ContentService.java +++ b/src/main/java/com/swyp/catsgotogedog/content/service/ContentService.java @@ -3,6 +3,10 @@ import com.swyp.catsgotogedog.User.domain.entity.User; import com.swyp.catsgotogedog.User.repository.UserRepository; import com.swyp.catsgotogedog.content.domain.entity.*; +import com.swyp.catsgotogedog.content.domain.entity.batch.information.FestivalInformation; +import com.swyp.catsgotogedog.content.domain.entity.batch.information.LodgeInformation; +import com.swyp.catsgotogedog.content.domain.entity.batch.information.RestaurantInformation; +import com.swyp.catsgotogedog.content.domain.entity.batch.information.SightsInformation; import com.swyp.catsgotogedog.content.domain.request.ContentRequest; import com.swyp.catsgotogedog.content.domain.response.ContentImageResponse; import com.swyp.catsgotogedog.content.domain.response.LastViewHistoryResponse; @@ -23,8 +27,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import java.util.List; -import java.util.Optional; +import java.util.*; import static java.time.LocalDateTime.now; @@ -43,6 +46,10 @@ public class ContentService { private final VisitHistoryRepository visitHistoryRepository; private final PetGuideRepository petGuideRepository; private final LastViewHistoryRepository lastViewHistoryRepository; + private final LodgeInformationRepository lodgeInformationRepository; + private final RestaurantInformationRepository restaurantInformationRepository; + private final SightsInformationRepository sightsInformationRepository; + private final FestivalInformationRepository festivalInformationRepository; private final ContentSearchService contentSearchService; @@ -66,16 +73,15 @@ public void saveContent(ContentRequest request){ contentElasticRepository.save(ContentDocument.from(content)); } - public PlaceDetailResponse getPlaceDetail(int contentId, String userId){ + public PlaceDetailResponse getPlaceDetail(int contentId, String userId, int contentTypeId){ + // 카테고리 공통 viewTotalRepository.upsertAndIncrease(contentId); if(userId != null){ recordView(userId, contentId); } - Content content = contentRepository.findByContentId(contentId); - double avg = contentSearchService.getAverageScore(contentId); boolean wishData = (userId != null) ? contentSearchService.getWishData(userId, contentId) : false; @@ -87,14 +93,28 @@ public PlaceDetailResponse getPlaceDetail(int contentId, String userId){ int totalView = viewTotalRepository.findTotalViewByContentId(contentId) .orElse(0); - List detailImage = getDetailImage(contentId); - PetGuide petGuide = getPetGuide(contentId) .orElse(null); + List detailImage = getDetailImage(contentId); + String restDate = contentSearchService.getRestDate(contentId); - return PlaceDetailResponse.from(content,avg,wishData,wishCnt,visited,totalView,detailImage,petGuide,restDate); + Content content = contentRepository.findByContentId(contentId); + + Map additional = getAdditionalInfo(contentId,contentTypeId); + + return PlaceDetailResponse.from( + content, + avg, + wishData, + wishCnt, + visited, + totalView, + detailImage, + petGuide, + restDate, + additional); } public boolean checkWish(String userId, int contentId){ @@ -255,4 +275,142 @@ private Content validateContent(int contentId) { .orElseThrow(() -> new CatsgotogedogException(ErrorCode.CONTENT_NOT_FOUND)); } + private Map getAdditionalInfo(int contentId, int contentTypeId) { + return switch (contentTypeId) { + case 15 -> getFestivalInfo(contentId); + case 32 -> getLodgeInfo(contentId); + case 39 -> getRestaurantInfo(contentId); + case 12 -> getSightsInfo(contentId); + default -> Map.of(); + }; + } + + private Map getFestivalInfo(int contentId) { + var e = festivalInformationRepository.findByContent_ContentId(contentId); + + if (e == null) return Map.of("type", "FESTIVAL"); + + var m = new HashMap(); + + m.put("type", "FESTIVAL"); + m.put("festivalId", e.getFestivalId()); + m.put("ageLimit", e.getAgeLimit()); + m.put("bookingPlace", e.getBookingPlace()); + m.put("discountInfo", e.getDiscountInfo()); + m.put("eventStartDate", e.getEventStartDate()); + m.put("eventEndDate", e.getEventEndDate()); + m.put("eventHomepage", e.getEventHomepage()); + m.put("eventPlace", e.getEventPlace()); + m.put("placeInfo", e.getPlaceInfo()); + m.put("playTime", e.getPlayTime()); + m.put("program", e.getProgram()); + m.put("spendTime", e.getSpendTime()); + m.put("organizer", e.getOrganizer()); + m.put("organizerTel", e.getOrganizerTel()); + m.put("supervisor", e.getSupervisor()); + m.put("supervisorTel", e.getSupervisorTel()); + m.put("subEvent", e.getSubEvent()); + m.put("feeInfo", e.getFeeInfo()); + + return m; + } + + private Map getLodgeInfo(int contentId) { + var e = lodgeInformationRepository.findByContent_ContentId(contentId); + + if (e == null) return Map.of("type", "LODGE"); + + var m = new HashMap(); + + m.put("type", "LODGE"); + m.put("lodgeId", e.getLodgeId()); + m.put("capacityCount", e.getCapacityCount()); + m.put("goodstay", e.getGoodstay()); + m.put("benikia", e.getBenikia()); + m.put("checkInTime", e.getCheckInTime()); + m.put("checkOutTime", e.getCheckOutTime()); + m.put("cooking", e.getCooking()); + m.put("foodplace", e.getFoodplace()); + m.put("hanok", e.getHanok()); + m.put("information", e.getInformation()); + m.put("parking", e.getParking()); + m.put("pickupService", e.getPickupService()); + m.put("roomCount", e.getRoomCount()); + m.put("reservationInfo", e.getReservationInfo()); + m.put("reservationUrl", e.getReservationUrl()); + m.put("roomType", e.getRoomType()); + m.put("scale", e.getScale()); + m.put("subFacility", e.getSubFacility()); + m.put("barbecue", e.getBarbecue()); + m.put("beauty", e.getBeauty()); + m.put("beverage", e.getBeverage()); + m.put("bicycle", e.getBicycle()); + m.put("campfire", e.getCampfire()); + m.put("fitness", e.getFitness()); + m.put("karaoke", e.getKaraoke()); + m.put("publicBath", e.getPublicBath()); + m.put("publicPcRoom", e.getPublicPcRoom()); + m.put("sauna", e.getSauna()); + m.put("seminar", e.getSeminar()); + m.put("sports", e.getSports()); + m.put("refundRegulation", e.getRefundRegulation()); + + return m; + } + + private Map getRestaurantInfo(int contentId) { + var e = restaurantInformationRepository.findByContent_ContentId(contentId); + + if (e == null) return Map.of("type", "RESTAURANT"); + + var m = new HashMap(); + + m.put("type", "RESTAURANT"); + m.put("restaurantId", e.getRestaurantId()); + m.put("chkCreditcard", e.getChkCreditcard()); + m.put("discountInfo", e.getDiscountInfo()); + m.put("signatureMenu", e.getSignatureMenu()); + m.put("information", e.getInformation()); + m.put("kidsFacility", e.getKidsFacility()); + m.put("openDate", e.getOpenDate()); + m.put("openTime", e.getOpenTime()); + m.put("takeout", e.getTakeout()); + m.put("parking", e.getParking()); + m.put("reservation", e.getReservation()); + m.put("restDate", e.getRestDate()); + m.put("scale", e.getScale()); + m.put("seat", e.getSeat()); + m.put("smoking", e.getSmoking()); + m.put("treatMenu", e.getTreatMenu()); + + return m; + } + + private Map getSightsInfo(int contentId) { + var e = sightsInformationRepository.findByContent_ContentId(contentId); + + if (e == null) return Map.of("type", "SIGHTS"); + + var m = new HashMap(); + + m.put("type", "SIGHTS"); + m.put("sightsId", e.getSightsId()); + m.put("contentTypeId", e.getContentTypeId()); + m.put("accomCount", e.getAccomCount()); + m.put("chkCreditcard", e.getChkCreditcard()); + m.put("expAgeRange", e.getExpAgeRange()); + m.put("expGuide", e.getExpGuide()); + m.put("infoCenter", e.getInfoCenter()); + m.put("openDate", e.getOpenDate()); + m.put("parking", e.getParking()); + m.put("restDate", e.getRestDate()); + m.put("useSeason", e.getUseSeason()); + m.put("useTime", e.getUseTime()); + m.put("heritage1", e.getHeritage1()); + m.put("heritage2", e.getHeritage2()); + m.put("heritage3", e.getHeritage3()); + + return m; + } + }