Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
DongGeon0908 committed Apr 6, 2024
2 parents 25dbc70 + e44256a commit b74ce4c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.core.api.item.entity.Item;
import com.core.api.item.entity.enums.ItemType;
import com.core.api.user.entity.User;
import lombok.Data;

import java.math.BigDecimal;
Expand All @@ -12,6 +13,7 @@
public class ItemDetailResponseDto {
private Long itemId;
private Long uid;
private String nickname;
private ItemType type;
private ItemType currentType;
private String message;
Expand All @@ -25,8 +27,8 @@ public class ItemDetailResponseDto {
public ItemDetailResponseDto(
Item item,
List<ItemDetailCommentDto> itemCommentList,
Long likeCounts
) {
Long likeCounts,
User use1) {
this.itemId = item.getId();
this.uid = item.getUid();
this.type = item.getType();
Expand All @@ -38,5 +40,6 @@ public ItemDetailResponseDto(
this.commentList = itemCommentList;
this.createdAt = item.getCreatedAt();
this.likeCounts = likeCounts;
this.nickname = use1.getNickname();
}
}
7 changes: 6 additions & 1 deletion src/main/java/com/core/api/item/service/ItemService.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.core.api.item.repository.ItemRepository;
import com.core.api.user.entity.User;
import com.core.api.user.repository.UserRepository;
import com.querydsl.core.Tuple;
import com.querydsl.core.types.Projections;
import com.querydsl.jpa.JPQLQueryFactory;
import com.querydsl.jpa.impl.JPAQueryFactory;
Expand Down Expand Up @@ -143,6 +144,10 @@ public ItemDetailResponseDto itemDetail(Long uId, Long itemId) {
.where(QItem.item.id.eq(itemId))
.fetchFirst();

User use1 = jpaQueryFactory.selectFrom(user)
.where(user.id.eq(item.getUid()))
.fetchFirst();

List<ItemDetailCommentDto> itemCommentList = jpaQueryFactory
.select(Projections.constructor(ItemDetailCommentDto.class,
itemComment.uid,
Expand All @@ -158,7 +163,7 @@ public ItemDetailResponseDto itemDetail(Long uId, Long itemId) {

Long likeCounts = itemLikeRepository.countByItemId(item.getId());

return new ItemDetailResponseDto(item, itemCommentList, likeCounts);
return new ItemDetailResponseDto(item, itemCommentList, likeCounts, use1);
}

public Integer itemCommentLike(Long id, Long itemCommentId) {
Expand Down

0 comments on commit b74ce4c

Please sign in to comment.