Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ public interface BookmarkUseCase {
List<BookmarkPreviewResponse> extractPreviewFromUrl(String url);

List<BookmarkPlatformResponse> getAllPlatforms(Long userId);

BookmarkResponse findBookmark(Long userId, Long bookmarkId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ public class BookmarkUseCaseImpl implements BookmarkUseCase {
private final BookmarkTagMappingRepository bookmarkTagMappingRepository;
private final BookmarkPlatformMapper bookmarkPlatformMapper;

@Override
@Transactional(readOnly = true)
public BookmarkResponse findBookmark(Long userId, Long bookmarkId){
User user = userGetService.findById(userId);
Bookmark bookmark = bookmarkGetService.getBookmarkById(bookmarkId);

validateBookmarkOwner(user.getId(), bookmark);

FileResponse fileResponse = fileMapper.toFileResponse(bookmark.getFile());
return bookmarkMapper.toResponse(bookmark, bookmarkGetService.getMappingsByBookmark(bookmark), fileResponse);
}

@Override
@Transactional(readOnly = true)
public Slice<BookmarkResponse> getFilteredBookmarks(Long userId, BookmarkSearchRequest request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,19 @@ public class BookmarkController {
private final BookmarkUseCase bookmarkUseCase;
private final NotificationUseCase notificationUseCase;

@GetMapping("/{bookmarkId}")
@Operation(summary = "북마크 단일 조회 API", description = "북마크를 조회합니다.")
public CommonResponse<BookmarkResponse> getBookmark(@CurrentUser Long userId, @PathVariable Long bookmarkId) {
BookmarkResponse response = bookmarkUseCase.findBookmark(userId, bookmarkId);
return CommonResponse.createSuccess(BOOKMARK_FIND_SUCCESS.getMessage(), response);
}

@PostMapping("/search")
@Operation(summary = "북마크 필터링 API")
public CommonResponse<Slice<BookmarkResponse>> getFilteredBookmarks(@CurrentUser Long userId,
@RequestBody @Valid BookmarkSearchRequest bookmarkSearchRequest) {
Slice<BookmarkResponse> responses = bookmarkUseCase.getFilteredBookmarks(userId, bookmarkSearchRequest);
return CommonResponse.createSuccess(BOOKMARK_FILTER_SUCCESS.getMessage(), responses);
return CommonResponse.createSuccess(BOOKMARK_FIND_SUCCESS.getMessage(), responses);
}

@PostMapping()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
@Getter
@AllArgsConstructor
public enum BookmarkResponseMessage {

BOOKMARK_FIND_SUCCESS("북마크 단일 조회에 성공했습니다"),
BOOKMARK_SEARCH_SUCCESS("북마크 검색에 성공했습니다."),
BOOKMARK_MEMO_SEARCH_SUCCESS("북마크 메모 검색에 성공했습니다."),
BOOKMARK_FILTER_SUCCESS("북마크 필터링에 성공했습니다."),
Expand Down