diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/advertisement/api/dto/AdvertisementResponse.java b/src/main/java/org/ktc2/cokaen/wouldyouin/advertisement/api/dto/AdvertisementResponse.java index 0eb32f70..5e9da066 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/advertisement/api/dto/AdvertisementResponse.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/advertisement/api/dto/AdvertisementResponse.java @@ -1,10 +1,13 @@ package org.ktc2.cokaen.wouldyouin.advertisement.api.dto; import java.time.LocalDateTime; +import java.util.Optional; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.ToString; import org.ktc2.cokaen.wouldyouin.advertisement.persist.Advertisement; +import org.ktc2.cokaen.wouldyouin.image.persist.AdvertisementImage; +import org.ktc2.cokaen.wouldyouin.image.persist.Image; @Builder @EqualsAndHashCode @@ -21,7 +24,10 @@ public static AdvertisementResponse from(Advertisement advertisement) { return AdvertisementResponse.builder() .id(advertisement.getId()) .title(advertisement.getTitle()) - .imageUrl(advertisement.getAdvertisementImage().getName()) + .imageUrl(Optional.of(advertisement) + .map((ad) -> advertisement.getAdvertisementImage()) + .map(Image::getName) + .orElse("")) .startTime(advertisement.getStartTime()) .endTime(advertisement.getEndTime()) .build(); diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/auth/application/oauth/dto/OauthResourcesResponse.java b/src/main/java/org/ktc2/cokaen/wouldyouin/auth/application/oauth/dto/OauthResourcesResponse.java index 8dcdf841..2489472d 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/auth/application/oauth/dto/OauthResourcesResponse.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/auth/application/oauth/dto/OauthResourcesResponse.java @@ -3,24 +3,16 @@ import lombok.Builder; import lombok.Getter; import lombok.RequiredArgsConstructor; +import lombok.ToString; @Getter @RequiredArgsConstructor @Builder +@ToString public class OauthResourcesResponse { private final String nickname; private final String email; private final String socialId; private final String profileImageUrl; - - @Override - public String toString() { - return "OauthResourcesResponse{" + - "nickname='" + nickname + '\'' + - ", email='" + email + '\'' + - ", socialId='" + socialId + '\'' + - ", profileImageUrl='" + profileImageUrl + '\'' + - '}'; - } } diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/curation/api/dto/CurationCreateRequest.java b/src/main/java/org/ktc2/cokaen/wouldyouin/curation/api/dto/CurationCreateRequest.java index 0fdf22d0..c21bdb79 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/curation/api/dto/CurationCreateRequest.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/curation/api/dto/CurationCreateRequest.java @@ -41,11 +41,8 @@ public class CurationCreateRequest { private List eventIds; @AssertTrue(message = "큐레이션 카드의 개수는 1개 이상 10개 이하이어야 합니다.") - public boolean isCurationCardsSizeValid() { - if (this.curationCards == null) { - return false; - } - return 1 <= this.curationCards.size() && this.curationCards.size() <= 10; + private boolean isCurationCardsSizeValid() { + return curationCards != null && 1 <= this.curationCards.size() && this.curationCards.size() <= 10; } public Curation toEntity(Curator curator, List curationCards, diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/curation/persist/Curation.java b/src/main/java/org/ktc2/cokaen/wouldyouin/curation/persist/Curation.java index b10cdf66..dab2245f 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/curation/persist/Curation.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/curation/persist/Curation.java @@ -98,11 +98,11 @@ public class Curation { public Curation(Curator curator, String title, String content, List curationCards, Area area, List hashtags, List events, String thumbnailUrl) { - this.curator = curator; - this.title = title; - this.content = content; + Optional.ofNullable(curator).ifPresent(this::setCurator); + Optional.ofNullable(title).ifPresent(this::setTitle); + Optional.ofNullable(content).ifPresent(this::setContent); Optional.ofNullable(curationCards).ifPresent(this::setCurationCards); - this.area = area; + Optional.ofNullable(area).ifPresent(this::setArea); Optional.ofNullable(hashtags).ifPresent(this::setHashtags); Optional.ofNullable(events).ifPresent(this::setEvents); Optional.ofNullable(thumbnailUrl).ifPresent(this::setThumbnailUrl); diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/curation/persist/CurationCard.java b/src/main/java/org/ktc2/cokaen/wouldyouin/curation/persist/CurationCard.java index 21a28aab..9f875961 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/curation/persist/CurationCard.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/curation/persist/CurationCard.java @@ -50,9 +50,9 @@ public class CurationCard { @Builder public CurationCard(String subtitle, String content, Curation curation, List images) { - this.subtitle = subtitle; - this.content = content; - this.curation = curation; + Optional.ofNullable(subtitle).ifPresent(this::setSubtitle); + Optional.ofNullable(content).ifPresent(this::setContent); + Optional.ofNullable(curation).ifPresent(this::setCuration); Optional.ofNullable(images).ifPresent(this::setCurationImages); } } \ No newline at end of file diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/curation/persist/CurationRepository.java b/src/main/java/org/ktc2/cokaen/wouldyouin/curation/persist/CurationRepository.java index 2e5291dd..a7165267 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/curation/persist/CurationRepository.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/curation/persist/CurationRepository.java @@ -19,6 +19,5 @@ public interface CurationRepository extends JpaRepository { @Query("SELECT C FROM Curation C JOIN FETCH C.curator " + "WHERE C.curator.id = :curatorId AND C.id < :lastId " + "ORDER BY C.id DESC") - Slice findAllByCuratorOrderByCreatedDateDesc(Long curatorId, Long lastId, - Pageable pageable); + Slice findAllByCuratorOrderByCreatedDateDesc(Long curatorId, Long lastId, Pageable pageable); } \ No newline at end of file diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/dto/EventCreateRequest.java b/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/dto/EventCreateRequest.java index d236ed3d..75db1e48 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/dto/EventCreateRequest.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/dto/EventCreateRequest.java @@ -62,7 +62,6 @@ public class EventCreateRequest { @NotNull(message = "카테고리는 필수입니다.") private Category category; - // TODO : 이미지 not null 고민, 큐레이션도! private List imageIds; @AssertTrue(message = "종료 시간은 시작 시간 이후여야 합니다.") @@ -75,7 +74,7 @@ private boolean isEndTimeAfterStartTime() { @AssertTrue(message = "이미지는 최대 5개까지 등록할 수 있습니다.") private boolean isImageSizeValid() { - return imageIds.size() <= 5; + return imageIds == null || imageIds.size() <= 5; } public Event toEntity(Host host, List images, String thumbnailUrl) { diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/dto/EventEditRequest.java b/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/dto/EventEditRequest.java index f06e9eab..ffd67f77 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/dto/EventEditRequest.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/dto/EventEditRequest.java @@ -71,6 +71,6 @@ private boolean isEndTimeAfterStartTime() { @AssertTrue(message = "이미지는 최대 5개까지 등록할 수 있습니다.") private boolean isImageSizeValid() { - return imageIds.size() <= 5; + return imageIds == null || imageIds.size() <= 5; } } \ No newline at end of file diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/dto/relationResonse/CurationEventResponse.java b/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/dto/relationResonse/CurationEventResponse.java index 5999bc91..242e1235 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/dto/relationResonse/CurationEventResponse.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/dto/relationResonse/CurationEventResponse.java @@ -1,12 +1,14 @@ package org.ktc2.cokaen.wouldyouin.event.api.dto.relationResonse; import java.time.LocalDateTime; +import java.util.Optional; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.ToString; import org.ktc2.cokaen.wouldyouin._common.vo.Location; import org.ktc2.cokaen.wouldyouin.event.persist.Event; +import org.ktc2.cokaen.wouldyouin.member.persist.BaseMember; @Getter @Builder @@ -29,7 +31,10 @@ public static CurationEventResponse from(Event event) { .location(event.getLocation()) .startTime(event.getStartTime()) .thumbnailImageUrl(event.getThumbnailUrl()) - .hostProfileImageUrl(event.getHost().getProfileImageUrl()) + .hostProfileImageUrl(Optional.of(event) + .map(Event::getHost) + .map(BaseMember::getProfileImageUrl) + .orElse("")) .hostNickname(event.getHost().getNickname()) .build(); } diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/event/persist/Event.java b/src/main/java/org/ktc2/cokaen/wouldyouin/event/persist/Event.java index d3e5686a..37e2301c 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/event/persist/Event.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/event/persist/Event.java @@ -102,7 +102,6 @@ public class Event { @Enumerated(EnumType.STRING) private Category category; - // Todo: 이미지를 사용하는 모든 엔티티 thumnail 설정 @Column(name = "thumbnail_url") private String thumbnailUrl; @@ -118,22 +117,21 @@ public class Event { protected Event(String title, String content, Host host, Area area, Location location, LocalDateTime startTime, LocalDateTime endTime, Integer price, Integer totalSeat, Category category, List images, String thumbnailUrl) { - this.title = title; - this.content = content; - this.host = host; - this.area = area; - this.location = location; - this.startTime = startTime; - this.endTime = endTime; - this.price = price; - this.totalSeat = totalSeat; - this.leftSeat = totalSeat; - this.category = category; + Optional.ofNullable(title).ifPresent(this::setTitle); + Optional.ofNullable(content).ifPresent(this::setContent); + Optional.ofNullable(host).ifPresent(this::setHost); + Optional.ofNullable(area).ifPresent(this::setArea); + Optional.ofNullable(location).ifPresent(this::setLocation); + Optional.ofNullable(startTime).ifPresent(this::setStartTime); + Optional.ofNullable(endTime).ifPresent(this::setEndTime); + Optional.ofNullable(price).ifPresent(this::setPrice); + Optional.ofNullable(totalSeat).ifPresent(this::setTotalSeat); + Optional.ofNullable(leftSeat).ifPresent(this::setLeftSeat); + Optional.ofNullable(category).ifPresent(this::setCategory); Optional.ofNullable(images).ifPresent(this::setImages); Optional.of(thumbnailUrl).ifPresent(this::setThumbnailUrl); } - // Todo: oneToMany 연관관계에서 모든 null 처리 public void updateFrom(EventEditRequest eventEditRequest, List images, String thumbnailUrl) { Optional.ofNullable(eventEditRequest.getTitle()).ifPresent(this::setTitle); Optional.ofNullable(eventEditRequest.getContent()).ifPresent(this::setContent); diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/relationResponse/EventHostResponse.java b/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/relationResponse/EventHostResponse.java index a3d82ee0..430a24f0 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/relationResponse/EventHostResponse.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/relationResponse/EventHostResponse.java @@ -34,7 +34,7 @@ public static EventHostResponse from(Host host) { .profileImageUrl(Optional.of(host) .map(BaseMember::getProfileImage) .map(Image::getName) - .orElse(null) + .orElse("") ) .intro(host.getIntro()) .likes(host.getLikes())