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: CartMember 존재하는지에 대한 여부 #122

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
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
Expand Up @@ -70,10 +70,10 @@ public class CartSingleResponse {
@Schema(description = "함께해요에 대한 상품관련 링크")
private List<ItemUrlResponse> itemUrls;

@Schema(description = "함께해요 참여했는지에 대한 여부")
private boolean isAlreadyJoin;



public static CartSingleResponse of(final Cart cart, final List<CartComment> activeComments) {
public static CartSingleResponse of(final Cart cart, final List<CartComment> activeComments, final boolean isAlreadyJoin) {

// 시간 포멧팅
String formattedCreatedDate = getFormattedCreatedDate(cart);
Expand Down Expand Up @@ -108,7 +108,7 @@ public static CartSingleResponse of(final Cart cart, final List<CartComment> act
.partyMax(cart.getPartyMax())
.status(cart.getStatus().name())
.writer(cart.getMember().getNickname())
// .writer(writerName)
.isAlreadyJoin(isAlreadyJoin)
.writtenTime(formattedCreatedDate)
.itemUrls(itemUrlsResponses)
.imageUrls(imageResponses)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ private List<String> getImageUrls(final List<MultipartFile> multipartFiles) {

/* -------------------------------------------- READ -------------------------------------------- */
public CartSingleResponse getSinglePost(final Long postId) {

Cart cartWithImg = cartRepository.findByIdFetchJoin(postId);
List<CartComment> activeComments = cartRepository.findActiveCommentsByCartId(postId);
CartSingleResponse cartSingleResponse = CartSingleResponse.of(cartWithImg, activeComments);
boolean isAlreadyJoin = cartMemberRepository.existsByMemberIdAndCartId(getCurrentMember().getId(), cartWithImg.getId());
CartSingleResponse cartSingleResponse = CartSingleResponse.of(cartWithImg, activeComments, isAlreadyJoin);
return cartSingleResponse;
}

Expand Down