22
33import com .sonkim .bookmarking .auth .entity .UserDetailsImpl ;
44import com .sonkim .bookmarking .common .aop .Idempotent ;
5- import com .sonkim .bookmarking .common .dto .PageResponseDto ;
5+ import com .sonkim .bookmarking .common .dto .CursorResultDto ;
66import com .sonkim .bookmarking .domain .bookmark .dto .BookmarkRequestDto ;
77import com .sonkim .bookmarking .domain .bookmark .dto .BookmarkResponseDto ;
88import com .sonkim .bookmarking .domain .bookmark .dto .BookmarkSearchCond ;
9- import com .sonkim .bookmarking .domain .bookmark .entity .Bookmark ;
109import com .sonkim .bookmarking .domain .bookmark .service .BookmarkService ;
1110import io .swagger .v3 .oas .annotations .Parameter ;
1211import io .swagger .v3 .oas .annotations .Operation ;
1514import io .swagger .v3 .oas .annotations .tags .Tag ;
1615import lombok .RequiredArgsConstructor ;
1716import lombok .extern .slf4j .Slf4j ;
18- import org .springframework .data .domain .Pageable ;
19- import org .springframework .data .web .PageableDefault ;
2017import org .springframework .http .HttpStatus ;
2118import org .springframework .http .ResponseEntity ;
2219import org .springframework .security .core .annotation .AuthenticationPrincipal ;
2320import org .springframework .stereotype .Controller ;
2421import org .springframework .web .bind .annotation .*;
2522
26- import java .util .Map ;
27-
2823@ Tag (name = "그룹 북마크 관리" , description = "그룹 내 북마크 생성 및 조회 API" )
2924@ Slf4j
3025@ RequiredArgsConstructor
@@ -42,58 +37,58 @@ public class TeamBookmarkController {
4237 })
4338 @ PostMapping ("/{groupId}/bookmarks" )
4439 @ Idempotent
45- public ResponseEntity <Map < String , Object > > createBookmark (@ AuthenticationPrincipal UserDetailsImpl userDetails ,
40+ public ResponseEntity <BookmarkResponseDto > createBookmark (@ AuthenticationPrincipal UserDetailsImpl userDetails ,
4641 @ PathVariable Long groupId ,
4742 @ RequestBody BookmarkRequestDto bookmarkRequestDto ) {
4843 log .info ("userId: {}, url: {} 북마크 생성 요청" , userDetails .getId (), bookmarkRequestDto .getUrl ());
49- Bookmark bookmark = bookmarkService .createBookmark (userDetails .getId (), groupId , bookmarkRequestDto );
50-
51- Map <String , Object > response = Map .of (
52- "message" , "Bookmark created successfully" ,
53- "bookmarkId" , bookmark .getId ()
54- );
44+ BookmarkResponseDto responseDto = bookmarkService .createBookmark (userDetails .getId (), groupId , bookmarkRequestDto );
5545
56- return ResponseEntity .status (HttpStatus .CREATED ).body (response );
46+ return ResponseEntity .status (HttpStatus .CREATED ).body (responseDto );
5747 }
5848
59- @ Operation (summary = "그룹 내 모든 북마크 조회 (페이징)" ,
49+ @ Operation (summary = "그룹 내 모든 북마크 조회 (커서 페이징)" ,
6050 description = "특정 그룹에 속한 모든 북마크를 페이징하여 조회합니다." ,
6151 parameters = {
62- @ Parameter (name = "page" , description = "표시할 페이지 (1부터 시작)" )
52+ @ Parameter (name = "cursor" , description = "다음 페이지를 위한 커서 ID(마지막으로 조회한 북마크 ID, 첫 페이지는 null)" ),
53+ @ Parameter (name = "size" , description = "한 페이지당 항목 수" )
6354 })
6455 @ ApiResponse (responseCode = "200" , description = "북마크 목록 조회 성공" )
6556 @ GetMapping ("/{groupId}/bookmarks" )
66- public ResponseEntity <PageResponseDto <BookmarkResponseDto >> getBookmarksOfGroup (
57+ public ResponseEntity <CursorResultDto <BookmarkResponseDto >> getBookmarksOfGroup (
6758 @ AuthenticationPrincipal UserDetailsImpl userDetails ,
6859 @ PathVariable ("groupId" ) Long groupId ,
6960 @ RequestParam (required = false ) String keyword ,
7061 @ RequestParam (required = false ) Long tagId ,
7162 @ RequestParam (required = false ) Long categoryId ,
72- @ Parameter (hidden = true ) @ PageableDefault (sort = "createdAt" ) Pageable pageable ) {
63+ @ RequestParam (required = false ) Long cursor ,
64+ @ RequestParam (required = false , defaultValue = "10" ) int size
65+ ) {
7366 // 검색 조건 DTO 생성
7467 BookmarkSearchCond cond = BookmarkSearchCond .builder ()
7568 .keyword (keyword )
7669 .tagId (tagId )
7770 .categoryId (categoryId )
7871 .build ();
7972
80- PageResponseDto <BookmarkResponseDto > bookmarkPage = bookmarkService .searchBookmarks (userDetails .getId (), groupId , cond , pageable );
73+ CursorResultDto <BookmarkResponseDto > bookmarkPage = bookmarkService .searchBookmarks (userDetails .getId (), groupId , cond , cursor , size );
8174 return ResponseEntity .ok (bookmarkPage );
8275 }
8376
84- @ Operation (summary = "지도 표시용 북마크 목록 조회 (필터링, 페이징)" ,
77+ @ Operation (summary = "지도 표시용 북마크 목록 조회 (필터링, 커서 페이징)" ,
8578 description = "특정 그룹에서 위치 정보가 있는 북마크를 조건(카테고리, 키워드, 태그)에 따라 필터링하여 조회합니다." ,
8679 parameters = {
87- @ Parameter (name = "page" , description = "표시할 페이지 (1부터 시작)" )
80+ @ Parameter (name = "cursor" , description = "다음 페이지를 위한 커서 ID(마지막으로 조회한 북마크 ID, 첫 페이지는 null)" ),
81+ @ Parameter (name = "size" , description = "한 페이지당 항목 수" )
8882 })
8983 @ GetMapping ("/{groupId}/bookmarks/map" )
90- public ResponseEntity <PageResponseDto <BookmarkResponseDto >> getBookmarksForMap (
84+ public ResponseEntity <CursorResultDto <BookmarkResponseDto >> getBookmarksForMap (
9185 @ AuthenticationPrincipal UserDetailsImpl userDetails ,
9286 @ Parameter (description = "북마크를 조회할 그룹 ID" ) @ PathVariable ("groupId" ) Long groupId ,
87+ @ RequestParam (required = false ) String keyword ,
9388 @ RequestParam (required = false ) Long categoryId ,
9489 @ RequestParam (required = false ) Long tagId ,
95- @ RequestParam (required = false ) String keyword ,
96- @ Parameter ( hidden = true ) @ PageableDefault ( size = 10 ) Pageable pageable
90+ @ RequestParam (required = false ) Long cursor ,
91+ @ RequestParam ( required = false , defaultValue = "10" ) int size
9792 ) {
9893 // 검색 조건 DTO 생성
9994 BookmarkSearchCond cond = BookmarkSearchCond .builder ()
@@ -103,7 +98,7 @@ public ResponseEntity<PageResponseDto<BookmarkResponseDto>> getBookmarksForMap(
10398 .forMap (true )
10499 .build ();
105100
106- PageResponseDto <BookmarkResponseDto > bookmarks = bookmarkService .searchBookmarks (userDetails .getId (), groupId , cond , pageable );
101+ CursorResultDto <BookmarkResponseDto > bookmarks = bookmarkService .searchBookmarks (userDetails .getId (), groupId , cond , cursor , size );
107102 return ResponseEntity .ok (bookmarks );
108103 }
109104}
0 commit comments