Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 회원별 북마크 목록 조회 시 productThumbnail 응답 추가 #87

Merged
merged 2 commits into from
Nov 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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