Skip to content

Commit b70db51

Browse files
committed
feat(community) : 댓글 최신순 정렬(comment Id 기준 내일차순) 조회 추가
1 parent 4ce6e0e commit b70db51

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

backend/src/main/java/com/backend/domain/community/dto/response/CommunityResponseDto.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99

1010
public record CommunityResponseDto(
1111
String userName,
12-
String userIamge,
12+
String userImage,
1313
String repositoryName,
14+
Long repositoryId,
1415
String summary,
1516
List<String> language,
1617
int totalScore,
@@ -21,6 +22,7 @@ public CommunityResponseDto(Repositories repositories, AnalysisResult analysis,
2122
repositories.getUser().getName(),
2223
repositories.getUser().getImageUrl(),
2324
repositories.getName(),
25+
repositories.getId(),
2426
analysis.getSummary(),
2527
repositories.getLanguages().stream()
2628
.map(language -> language.getLanguage().name())

backend/src/main/java/com/backend/domain/community/repository/CommentRepository.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@
1010
@Repository
1111
public interface CommentRepository extends JpaRepository<Comment, Long> {
1212
List<Comment> findByAnalysisResult_Id(Long analysisResultId);
13+
List<Comment> findByAnalysisResultIdOrderByIdDesc(Long analysisResultId);
1314
}

backend/src/main/java/com/backend/domain/community/service/CommunityService.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,14 @@ public Comment addComment(Long analysisResultId, Long memberId, String content)
5050
return commentRepository.save(comment);
5151
}
5252

53-
// 특정 분석 결과의 댓글 조회
53+
// // 특정 분석 결과의 댓글 조회
54+
// public List<Comment> getCommentsByAnalysisResult(Long analysisResultId) {
55+
// return commentRepository.findByAnalysisResult_Id(analysisResultId);
56+
// }
57+
5458
public List<Comment> getCommentsByAnalysisResult(Long analysisResultId) {
55-
return commentRepository.findByAnalysisResult_Id(analysisResultId);
59+
// id 내림차순으로 정렬된 댓글 리스트 반환
60+
return commentRepository.findByAnalysisResultIdOrderByIdDesc(analysisResultId);
5661
}
5762

5863
// 댓글 삭제

0 commit comments

Comments
 (0)