Skip to content
This repository has been archived by the owner on Oct 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #210 from FinFellows/develop
Browse files Browse the repository at this point in the history
[FIX] 뉴스컨텐츠 상세 조회시 북마크 리턴 값 수정
  • Loading branch information
LEEJaeHyeok97 authored Jan 18, 2024
2 parents ab3de49 + a5ece2a commit cdaaf0f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,18 @@ public Page<NewsContentResponse> getAllNewsContents(Long userId, Pageable pageab
return new PageImpl<>(newsContentsResponses, pageable, newsContentsPage.getTotalElements());
}

public NewsContentResponse getNewsContent(Long id) {
public NewsContentResponse getNewsContent(Long id, Long userId) {
NewsContent newsContent = newsContentRepository.findById(id)
.orElseThrow(() -> new EntityNotFoundException("NewsContent not found with id: " + id));

boolean isBookmarked = userId != null && checkBookmarked(userId, id);

return NewsContentResponse.builder()
.id(newsContent.getId())
.created_at(newsContent.getCreatedAt())
.title(newsContent.getTitle())
.content(newsContent.getContent())
.bookmarked(isBookmarked)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ public ResponseEntity<Page<NewsContentResponse>> getAllNewsContents(@CurrentUser
@Content(mediaType = "application/json", schema = @Schema(implementation = NewsContentResponse.class))
})
@GetMapping("/{id}")
public ResponseEntity<NewsContentResponse> getNewsContent(@PathVariable Long id) {
NewsContentResponse response = newsContentService.getNewsContent(id);
public ResponseEntity<NewsContentResponse> getNewsContent(@PathVariable Long id, @CurrentUser UserPrincipal userPrincipal) {
Long userId = userPrincipal != null ? userPrincipal.getId() : null;
NewsContentResponse response = newsContentService.getNewsContent(id, userId);
return new ResponseEntity<>(response, HttpStatus.OK);
}

Expand Down

0 comments on commit cdaaf0f

Please sign in to comment.