diff --git a/src/main/java/com/jeju/nanaland/domain/nana/dto/NanaResponse.java b/src/main/java/com/jeju/nanaland/domain/nana/dto/NanaResponse.java index 4999aace..ac17e81f 100644 --- a/src/main/java/com/jeju/nanaland/domain/nana/dto/NanaResponse.java +++ b/src/main/java/com/jeju/nanaland/domain/nana/dto/NanaResponse.java @@ -59,12 +59,6 @@ public static class NanaDetailDto { @Schema(description = "게시물 데이터") private List nanaDetails; - @QueryProjection - public NanaDetailDto(String originUrl, String notice, List nanaDetails) { - this.originUrl = originUrl; - this.notice = notice; - this.nanaDetails = nanaDetails; - } } @Data @@ -91,13 +85,20 @@ public static class NanaDetail { @Schema(description = "게시물 설명") public String content; - @QueryProjection - public NanaDetail(int number, String subTitle, String title, String imageUrl, String content) { - this.number = number; - this.subTitle = subTitle; - this.title = title; - this.imageUrl = imageUrl; - this.content = content; - } + public List additionalInfoList; + + } + + @Data + @Builder + @Schema(description = "나나's pick 각 게시글 부가 정보") + public static class NanaAdditionalInfo { + + @Schema(description = "부가 정보 key 값 ex: 주차정보, 스페셜, 예약링크,,") + public String infoKey; + + @Schema(description = "부가 정보 value 값") + public String infoValue; + } } diff --git a/src/main/java/com/jeju/nanaland/domain/nana/entity/InfoType.java b/src/main/java/com/jeju/nanaland/domain/nana/entity/InfoType.java new file mode 100644 index 00000000..fc3e7fbe --- /dev/null +++ b/src/main/java/com/jeju/nanaland/domain/nana/entity/InfoType.java @@ -0,0 +1,26 @@ +package com.jeju.nanaland.domain.nana.entity; + +public enum InfoType { + ADDRESS("주소"), + PARKING("주차"), + SPECIAL("스페셜"), + AMENITY("편의시설"), + WEBSITE("홈페이지"), + RESERVATION_LINK("예약링크"), + AGE("이용연령"), + TIME("이용시간"), + FEE("이용요금"), + DATE("이용날짜"), + DESCRIPTION("소개"); + + + private final String description; + + InfoType(String description) { + this.description = description; + } + + public String getDescription() { + return description; + } +} diff --git a/src/main/java/com/jeju/nanaland/domain/nana/entity/NanaAdditionalInfo.java b/src/main/java/com/jeju/nanaland/domain/nana/entity/NanaAdditionalInfo.java new file mode 100644 index 00000000..8bd5f190 --- /dev/null +++ b/src/main/java/com/jeju/nanaland/domain/nana/entity/NanaAdditionalInfo.java @@ -0,0 +1,19 @@ +package com.jeju.nanaland.domain.nana.entity; + +import com.jeju.nanaland.domain.common.entity.BaseEntity; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@Entity +@NoArgsConstructor +public class NanaAdditionalInfo extends BaseEntity { + + @Enumerated(EnumType.STRING) + private InfoType infoType; + + private String description; +} diff --git a/src/main/java/com/jeju/nanaland/domain/nana/entity/NanaContent.java b/src/main/java/com/jeju/nanaland/domain/nana/entity/NanaContent.java index 546e56bb..bba1c399 100644 --- a/src/main/java/com/jeju/nanaland/domain/nana/entity/NanaContent.java +++ b/src/main/java/com/jeju/nanaland/domain/nana/entity/NanaContent.java @@ -6,8 +6,12 @@ import jakarta.persistence.Entity; import jakarta.persistence.FetchType; import jakarta.persistence.JoinColumn; +import jakarta.persistence.JoinTable; +import jakarta.persistence.ManyToMany; import jakarta.persistence.ManyToOne; import jakarta.validation.constraints.NotBlank; +import java.util.HashSet; +import java.util.Set; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; @@ -40,6 +44,13 @@ public class NanaContent extends BaseEntity { @Column(columnDefinition = "TEXT") private String content; + @ManyToMany + @JoinTable(name = "NANA_INFO_TYPE", + joinColumns = @JoinColumn(name = "nana_contet_id"), + inverseJoinColumns = @JoinColumn(name = "nana_additional_info_id") + ) + private Set infoList; + @Builder public NanaContent(NanaTitle nanaTitle, ImageFile imageFile, int number, String subTitle, String title, String content) { @@ -49,5 +60,6 @@ public NanaContent(NanaTitle nanaTitle, ImageFile imageFile, int number, String this.subTitle = subTitle; this.title = title; this.content = content; + this.infoList = new HashSet<>(); } } diff --git a/src/main/java/com/jeju/nanaland/domain/nana/service/NanaService.java b/src/main/java/com/jeju/nanaland/domain/nana/service/NanaService.java index 79fb789a..c8b1269d 100644 --- a/src/main/java/com/jeju/nanaland/domain/nana/service/NanaService.java +++ b/src/main/java/com/jeju/nanaland/domain/nana/service/NanaService.java @@ -4,6 +4,7 @@ import com.jeju.nanaland.domain.nana.dto.NanaResponse; import com.jeju.nanaland.domain.nana.dto.NanaResponse.NanaThumbnail; import com.jeju.nanaland.domain.nana.dto.NanaResponse.NanaThumbnailDto; +import com.jeju.nanaland.domain.nana.entity.NanaAdditionalInfo; import com.jeju.nanaland.domain.nana.entity.NanaContent; import com.jeju.nanaland.domain.nana.entity.NanaTitle; import com.jeju.nanaland.domain.nana.repository.NanaContentRepository; @@ -12,6 +13,7 @@ import com.jeju.nanaland.global.exception.BadRequestException; import java.util.ArrayList; import java.util.List; +import java.util.Set; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; @@ -54,8 +56,11 @@ public NanaThumbnailDto getNanaThumbnails(Locale locale, int page, int size) { //나나 상세 게시물 public NanaResponse.NanaDetailDto getNanaDetail(Long id) { + // nanaTitle 찾아서 NanaTitle nanaTitle = nanaTitleRepository.findNanaTitleById(id) .orElseThrow(() -> new BadRequestException("존재하지 않는 Nana 컨텐츠 입니다.")); + + // nanaTitle에 맞는 게시물 조회 List nanaContentList = nanaContentRepository.findAllByNanaTitleOrderByNumber( nanaTitle); @@ -69,6 +74,7 @@ public NanaResponse.NanaDetailDto getNanaDetail(Long id) { .title(nanaContent.getTitle()) .imageUrl(nanaContent.getImageFile().getOriginUrl()) .content(nanaContent.getContent()) + .additionalInfoList(getAdditionalInfoFromNanaContentEntity(nanaContent)) .build()); } @@ -80,4 +86,23 @@ public NanaResponse.NanaDetailDto getNanaDetail(Long id) { .build(); } -} + + // nanaContent의 AdditionalInfo dto로 바꾸기 + public List getAdditionalInfoFromNanaContentEntity( + NanaContent nanaContent) { + Set eachInfoList = nanaContent.getInfoList(); + + // 순서 보장 위해 List 형으로 바꾸고 + List nanaAdditionalInfos = new ArrayList<>(eachInfoList); + + //DTO 형태로 변환 + List result = new ArrayList<>(); + for (NanaAdditionalInfo info : nanaAdditionalInfos) { + result.add(NanaResponse.NanaAdditionalInfo.builder() + .infoKey(info.getInfoType().getDescription()) + .infoValue(info.getDescription()) + .build()); + } + return result; + } +} \ No newline at end of file