Skip to content

Commit

Permalink
fix: 상세 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
thgr8ganzi committed Apr 6, 2024
1 parent a2b5696 commit 11b1e8b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 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();
}
}
8 changes: 6 additions & 2 deletions 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 @@ -138,10 +139,13 @@ public void deleteById(Long id) {

public ItemDetailResponseDto itemDetail(Long uId, Long itemId) {

Item item = jpaQueryFactory.select(QItem.item)
Tuple tuple = jpaQueryFactory.select(QItem.item, user)
.from(QItem.item)
.where(QItem.item.id.eq(itemId))
.leftJoin(user).on(QItem.item.uid.eq(user.id))
.fetchFirst();
Item item = tuple.get(QItem.item);
User use1 = tuple.get(user);

List<ItemDetailCommentDto> itemCommentList = jpaQueryFactory
.select(Projections.constructor(ItemDetailCommentDto.class,
Expand All @@ -158,7 +162,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 11b1e8b

Please sign in to comment.