Skip to content

Commit

Permalink
refactor: commentController 변경 (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
xxoznge authored Jul 4, 2024
1 parent 81aca25 commit ad5953e
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.ddabong.ddabongdotchiBE.domain.comment.controller;

import java.util.Collections;
import java.util.List;

import org.springframework.web.bind.annotation.GetMapping;
Expand Down Expand Up @@ -42,10 +41,6 @@ public ApiResponse<CommentCreateResponse> createComment(

@GetMapping("/{cardId}")
public ApiResponse<List<CommentGetResponse>> getComment(@PathVariable Long cardId) {
List<CommentGetResponse> commentResponses = commentQueryService.getComment(cardId);
if (!commentResponses.isEmpty()) {
return ApiResponse.onSuccess(commentResponses);
}
return ApiResponse.onSuccess(Collections.emptyList());
return ApiResponse.onSuccess(commentQueryService.getComment(cardId));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class CommentQueryService {
public List<CommentGetResponse> getComment(Long cardId) {
return commentRepository.findByCardIdOrderByCreatedAtDesc(cardId)
.stream()
.map(comment -> CommentGetResponse.from(comment))
.map(CommentGetResponse::from)
.toList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public CommentCreateResponse createComment(
User authUser,
CommentCreateRequest request
) {

Card card = cardRepository.findById(request.cardId())
.orElseThrow(() -> new CardExceptionHandler(CardErrorCode.CARD_NOT_FOUND));

Expand Down

0 comments on commit ad5953e

Please sign in to comment.