From 6c472399e4ae0e951bb66604fe63325be4f64fec Mon Sep 17 00:00:00 2001 From: lej8924 Date: Tue, 23 Jul 2024 00:58:39 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix:=20=ED=8B=B0=ED=81=B4?= =?UTF-8?q?=EB=AC=B8=EB=8B=B5=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ticle/server/mypage/dto/response/QnAResponse.java | 2 +- .../java/com/ticle/server/mypage/service/MyPageService.java | 3 ++- .../com/ticle/server/opinion/repository/OpinionRepository.java | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/ticle/server/mypage/dto/response/QnAResponse.java b/src/main/java/com/ticle/server/mypage/dto/response/QnAResponse.java index 8a241d2..4f8923d 100644 --- a/src/main/java/com/ticle/server/mypage/dto/response/QnAResponse.java +++ b/src/main/java/com/ticle/server/mypage/dto/response/QnAResponse.java @@ -13,5 +13,5 @@ public class QnAResponse { private String question; private String comment; - private LocalDateTime createdDate; + private String createdDate; } diff --git a/src/main/java/com/ticle/server/mypage/service/MyPageService.java b/src/main/java/com/ticle/server/mypage/service/MyPageService.java index 3b5c612..8157c14 100644 --- a/src/main/java/com/ticle/server/mypage/service/MyPageService.java +++ b/src/main/java/com/ticle/server/mypage/service/MyPageService.java @@ -28,6 +28,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.time.format.DateTimeFormatter; import java.util.List; import java.util.Optional; import java.util.stream.Collectors; @@ -105,7 +106,7 @@ public List getMyQnA(Long userId, Pageable pageable) { log.info("Fetching comment for userId: {}, opinionId: {}", userId, comment.getOpinion().getOpinionId()); Opinion opinion = opinionRepository.findByOpinionIdWithFetch(comment.getOpinion().getOpinionId()) .orElseThrow(() -> new RuntimeException("댓글이 없습니다")); - return new QnAResponse(opinion.getQuestion(), comment.getContent(), opinion.getCreatedDate()); + return new QnAResponse(opinion.getQuestion(), comment.getContent(), opinion.getCreatedDate().format(DateTimeFormatter.ISO_DATE_TIME)); }) .collect(Collectors.toList()); } diff --git a/src/main/java/com/ticle/server/opinion/repository/OpinionRepository.java b/src/main/java/com/ticle/server/opinion/repository/OpinionRepository.java index 061411d..65f7150 100644 --- a/src/main/java/com/ticle/server/opinion/repository/OpinionRepository.java +++ b/src/main/java/com/ticle/server/opinion/repository/OpinionRepository.java @@ -6,6 +6,7 @@ import org.springframework.data.jpa.repository.EntityGraph; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; import java.util.List; @@ -17,7 +18,7 @@ public interface OpinionRepository extends JpaRepository { @Query("SELECT o " + "FROM Opinion o JOIN FETCH Comment c on o.opinionId = c.opinion.opinionId " + "WHERE o.opinionId = :opinionId") - Optional findByOpinionIdWithFetch(Long opinionId); + Optional findByOpinionIdWithFetch(@Param("opinionId") Long opinionId); @EntityGraph(attributePaths = {"comments", "comments.user"}) Page findAll(Pageable pageable);