Skip to content

Commit

Permalink
๐Ÿ› Fix: ํ‹ฐํด๋ฌธ๋‹ต ์ˆ˜์ •
Browse files Browse the repository at this point in the history
  • Loading branch information
lej8924 committed Jul 22, 2024
1 parent cacc505 commit 6c47239
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ public class QnAResponse {

private String question;
private String comment;
private LocalDateTime createdDate;
private String createdDate;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -105,7 +106,7 @@ public List<QnAResponse> 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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -17,7 +18,7 @@ public interface OpinionRepository extends JpaRepository<Opinion, Long> {
@Query("SELECT o " +
"FROM Opinion o JOIN FETCH Comment c on o.opinionId = c.opinion.opinionId " +
"WHERE o.opinionId = :opinionId")
Optional<Opinion> findByOpinionIdWithFetch(Long opinionId);
Optional<Opinion> findByOpinionIdWithFetch(@Param("opinionId") Long opinionId);

@EntityGraph(attributePaths = {"comments", "comments.user"})
Page<Opinion> findAll(Pageable pageable);
Expand Down

0 comments on commit 6c47239

Please sign in to comment.