Skip to content

Commit 4eecce4

Browse files
committed
hotfix: 댓글 조회시 userId 값 로직 변경
1 parent 1731b0f commit 4eecce4

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/main/java/com/bigpicture/moonrabbit/domain/answer/controller/AnswerController.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,15 @@ public ResponseEntity<AnswerResponseDTO> deleteAnswer(@PathVariable Long id) {
6969
@Operation(summary = "게시글 댓글 조회", description = "게시글 ID로 댓글 목록 조회 (닉네임, 프로필, 부모ID 포함)")
7070
@GetMapping("/board/{boardId}")
7171
public ResponseEntity<List<AnswerResponseDTO>> getAnswersByBoard(@PathVariable Long boardId) {
72-
List<AnswerResponseDTO> answers = answerService.getAnswersByBoard(boardId, null);
72+
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
73+
Long currentUserId = null;
74+
75+
if (authentication.getPrincipal() != null && !"anonymousUser".equals(authentication.getPrincipal().toString())) {
76+
String email = authentication.getName();
77+
currentUserId = userService.getUserIdByEmail(email);
78+
}
79+
80+
List<AnswerResponseDTO> answers = answerService.getAnswersByBoard(boardId, currentUserId);
7381
return new ResponseEntity<>(answers, HttpStatus.OK);
7482
}
7583

0 commit comments

Comments
 (0)