Skip to content

Commit

Permalink
[fix] 관심상품 chatRoomId 문제 해결 (#160)
Browse files Browse the repository at this point in the history
* #153 fix: 채팅창 목록 조회 문제 해결

- 채팅창만이 존재하고 채팅 로그가 없는 경우가 원인이었습니다.

* #153 fix: nextMessageId가 응답되도록 수정

* #153 fix: 필드멤버 명 변경

* #153 fix: 오타 수정

* #153 fix: 채팅 메시지 목록 조회시 새로운 메시지가 없는 경우 408 -> 200으로 변경

* #153 feat; 채팅방에 없는 회원이 채팅 메시지 목록 조회 요청시 인가 오류 구현

* #153 feat; equalItemId 조건절 별도의 메소드로 구현

* #153 fix: 관심상품 목록 조회시 본인이 관심 등록한 상품 게시글만 조회하도록 변경

* #153 fix: 관심상품 문제 해결
  • Loading branch information
yonghwankim-dev authored Oct 5, 2023
1 parent a9c0522 commit 6340aab
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ public ItemDetailResponse findDetailItemBy(Long itemId, Principal principal) {
boolean isInWishList = wishRepository.existsByMemberIdAndItemId(principal.getMemberId(), itemId);

if (item.isSeller(principal.getMemberId())) {
Long chatRoomId = chatRoomRepository.findByItemIdAndMemberId(itemId, principal.getMemberId())
.orElse(null);
return ItemDetailResponse.toSeller(item, principal.getMemberId(), imageUrls, isInWishList, chatRoomId);
return ItemDetailResponse.toSeller(item, principal.getMemberId(), imageUrls, isInWishList);
}
return ItemDetailResponse.toBuyer(item, principal.getMemberId(), imageUrls, isInWishList);
Long chatRoomId = chatRoomRepository.findByItemIdAndMemberId(itemId, principal.getMemberId())
.orElse(null);
return ItemDetailResponse.toBuyer(item, principal.getMemberId(), imageUrls, isInWishList, chatRoomId);
}

@Transactional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private ItemDetailResponse(boolean isSeller, List<String> imageUrls, String sell
}

public static ItemDetailResponse toBuyer(Item item, Long loginMemberId, List<String> imageUrls,
boolean isInWishList) {
boolean isInWishList, Long chatRoomId) {
Member seller = item.getMember();
boolean isSeller = seller.equalId(loginMemberId);
return ItemDetailResponse.builder()
Expand All @@ -68,11 +68,12 @@ public static ItemDetailResponse toBuyer(Item item, Long loginMemberId, List<Str
.viewCount(item.getViewCount())
.price(item.getPrice())
.isInWishList(isInWishList)
.chatRoomId(chatRoomId)
.build();
}

public static ItemDetailResponse toSeller(Item item, Long loginMemberId, List<String> imageUrls,
boolean isInWishList, Long chatRoomId) {
boolean isInWishList) {
Member seller = item.getMember();
boolean isSeller = seller.equalId(loginMemberId);
return ItemDetailResponse.builder()
Expand All @@ -89,7 +90,6 @@ public static ItemDetailResponse toSeller(Item item, Long loginMemberId, List<St
.viewCount(item.getViewCount())
.price(item.getPrice())
.isInWishList(isInWishList)
.chatRoomId(chatRoomId)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ public void findDetailItemBySeller() throws Exception {
"가락동", "thumbnailUrl", seller, sport);
List<String> imageUrls = List.of("imageUrlValue1", "imageUrlValue2");

ItemDetailResponse response = ItemDetailResponse.toBuyer(item, seller.getId(), imageUrls, false);
ItemDetailResponse response = ItemDetailResponse.toBuyer(item, seller.getId(), imageUrls, false, null);
given(itemService.findDetailItemBy(any(), any())).willReturn(response);

// when & then
mockMvc.perform(get("/api/items/1"))
.andExpect(status().isOk())
Expand Down Expand Up @@ -102,7 +103,7 @@ public void findDetailItemByBuyer() throws Exception {
Long loginMemberId = 9999L;
List<String> imageUrls = List.of("imageUrlValue1", "imageUrlValue2");

ItemDetailResponse response = ItemDetailResponse.toSeller(item, loginMemberId, imageUrls, false, 1L);
ItemDetailResponse response = ItemDetailResponse.toSeller(item, loginMemberId, imageUrls, false);
given(itemService.findDetailItemBy(any(), any())).willReturn(response);
// when & then
mockMvc.perform(get("/api/items/1"))
Expand Down

0 comments on commit 6340aab

Please sign in to comment.