Skip to content

Commit

Permalink
Merge pull request #87 from efub-ecyce/feat/bookmark
Browse files Browse the repository at this point in the history
feat: 회원별 북마크 목록 조회 시 productThumbnail 응답 추가
  • Loading branch information
stopsilver123 authored Nov 30, 2024
2 parents d8b6623 + c16db7f commit 430f72c
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ecyce.karma.domain.bookmark.dto;

import com.ecyce.karma.domain.bookmark.entity.Bookmark;
import com.ecyce.karma.domain.product.entity.Product;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand All @@ -12,20 +13,28 @@ public class BookmarkDto {
private String productName;
private int price;
private int duration;
private String productThumbnail;

public BookmarkDto(Long bookmarkId, String productName, int price, int duration) {
public BookmarkDto(Long bookmarkId, String productName, int price, int duration, String productThumbnail) {
this.bookmarkId = bookmarkId;
this.productName = productName;
this.price = price;
this.duration = duration;
this.productThumbnail = productThumbnail;
}

public static BookmarkDto from(Bookmark bookmark) {
Product product = bookmark.getProduct();
String productThumbnail = null;
if (product.getProductImages() != null && !product.getProductImages().isEmpty()) {
productThumbnail = product.getProductImages().get(0).getProductImgUrl();
}
return new BookmarkDto(
bookmark.getBookmarkId(),
bookmark.getProduct().getProductName(),
bookmark.getProduct().getPrice(),
bookmark.getProduct().getDuration()
bookmark.getProduct().getDuration(),
productThumbnail
);
}
}
Expand Down

0 comments on commit 430f72c

Please sign in to comment.