22
33import com .jocketdan .tour .dto .BookmarkCountDTO ;
44import com .jocketdan .tour .dto .PaginatedResponseDTO ;
5- import com .jocketdan .tour .dto .ResponsePlaceDTO ;
5+ import com .jocketdan .tour .dto .ResponseBookmarkDTO ;
66import com .jocketdan .tour .entity .BookmarkType ;
77import com .jocketdan .tour .service .BookmarkService ;
88import io .swagger .v3 .oas .annotations .Operation ;
@@ -32,38 +32,24 @@ public class BookmarkController {
3232 @ Operation (
3333 summary = "북마크 추가" ,
3434 description = """
35- 특정 관광지를 북마크에 추가합니다.
36-
37- ### 파라미터 설명
38- - **placeId**: OPEN API의 contentId (예: "126508", "264636")
39- - **contentTypeId**: 콘텐츠 타입 ID
40- - 12: 관광지
41- - 14: 문화시설
42- - 15: 축제 (자동으로 FESTIVAL 타입으로 분류)
43- - 28: 레포츠
44- - 32: 숙박
45- - 38: 쇼핑
46- - 39: 음식점
35+ 특정 관광지를 북마크에 추가 시 DB에 OPEN API 정보들을 같이 저장합니다.
4736
4837 ### 예시
4938 ```
50- POST /tour/bookmarks?placeId =126508&contentTypeId=12
39+ POST /tour/bookmarks?contentId =126508
5140 ```
5241 """ ,
5342 tags = {"북마크 관리" }
5443 )
5544 @ PostMapping ("/bookmarks" )
5645 public ResponseEntity <Void > addBookmark (
5746 @ Parameter (description = "OPEN API contentId" , required = true )
58- @ RequestParam String placeId ,
59-
60- @ Parameter (description = "콘텐츠 타입 ID (12=관광지, 15=축제 등)" , required = true )
61- @ RequestParam Integer contentTypeId ,
47+ @ RequestParam String contentId ,
6248
6349 Authentication authentication
6450 ) {
6551 String userEmail = authentication .getName ();
66- bookmarkService .addBookmark (placeId , contentTypeId , userEmail );
52+ bookmarkService .addBookmark (contentId , userEmail );
6753 return ResponseEntity .status (HttpStatus .CREATED ).build ();
6854 }
6955
@@ -74,34 +60,33 @@ public ResponseEntity<Void> addBookmark(
7460 여러 개를 동시에 삭제할 수 있습니다.
7561
7662 ### 예시
77- - 단일 삭제: `DELETE /tour/bookmarks?placeIds =126508`
78- - 다중 삭제: `DELETE /tour/bookmarks?placeIds =126508,264636,125406`
63+ - 단일 삭제: `DELETE /tour/bookmarks?contentIds =126508`
64+ - 다중 삭제: `DELETE /tour/bookmarks?contentIds =126508,264636,125406`
7965 """ ,
8066 tags = {"북마크 관리" }
8167 )
8268 @ DeleteMapping ("/bookmarks" )
8369 public ResponseEntity <Void > removeBookmark (
8470 @ Parameter (
85- name = "placeIds " ,
86- description = "삭제할 placeId (쉼표로 구분하여 여러 개 가능)" ,
71+ name = "contentIds " ,
72+ description = "삭제할 contentId (쉼표로 구분하여 여러 개 가능)" ,
8773 required = true ,
88- example = "126508,264636" ,
8974 schema = @ Schema (type = "string" )
9075 )
91- @ RequestParam List <String > placeIds ,
76+ @ RequestParam List <String > contentIds ,
9277
9378 Authentication authentication
9479 ) {
9580 String userEmail = authentication .getName ();
96- bookmarkService .removeBookmark (placeIds , userEmail );
81+ bookmarkService .removeBookmark (contentIds , userEmail );
9782 return ResponseEntity .noContent ().build ();
9883 }
9984
10085 @ Operation (
10186 summary = "내 북마크 목록 조회" ,
10287 description = """
10388 현재 로그인한 사용자의 북마크 목록을 조회합니다.
104- OPEN API에서 실시간으로 장소 정보를 가져와 함께 반환합니다.
89+ DB에 저장한 OPEN API에서 장소 정보를 가져와 함께 반환합니다.
10590
10691 ### 타입별 조회
10792 - **type=TOUR**: 일반 관광지 북마크만 조회
@@ -112,7 +97,7 @@ public ResponseEntity<Void> removeBookmark(
11297 ### 정렬 (arrange)
11398 - **T**: 제목 오름차순
11499 - **C**: 최신 북마크 순 (기본값)
115- - **R**: 평균 별점 높은 순
100+ ` - **R**: 평균 별점 높은 순 (추후 구현 예정 / 아직 구현 안됐습니다)`
116101
117102 ### 예시
118103 ```
@@ -122,11 +107,8 @@ public ResponseEntity<Void> removeBookmark(
122107 tags = {"북마크 관리" }
123108 )
124109 @ GetMapping ("/bookmarks/my" )
125- public ResponseEntity <PaginatedResponseDTO <ResponsePlaceDTO >> getMyBookmarks (
126- @ Parameter (description = "페이지당 항목 수" , example = "10" )
110+ public ResponseEntity <PaginatedResponseDTO <ResponseBookmarkDTO >> getMyBookmarks (
127111 @ RequestParam (defaultValue = "10" ) int numOfRows ,
128-
129- @ Parameter (description = "페이지 번호 (1부터 시작)" , example = "1" )
130112 @ RequestParam (defaultValue = "1" ) int pageNo ,
131113
132114 @ Parameter (description = "정렬 기준 (T=제목, C=최신, R=별점)" , example = "C" )
@@ -141,7 +123,7 @@ public ResponseEntity<PaginatedResponseDTO<ResponsePlaceDTO>> getMyBookmarks(
141123 Pageable pageable = PageRequest .of (pageNo - 1 , numOfRows , sort );
142124
143125 String userEmail = authentication .getName ();
144- Page <ResponsePlaceDTO > myBookmarks = bookmarkService .getMyBookmarks (userEmail , type , pageable );
126+ Page <ResponseBookmarkDTO > myBookmarks = bookmarkService .getMyBookmarks (userEmail , type , pageable );
145127
146128 return ResponseEntity .ok (PaginatedResponseDTO .of (myBookmarks ));
147129 }
@@ -169,48 +151,9 @@ public ResponseEntity<BookmarkCountDTO> getMyBookmarkCount(
169151 return ResponseEntity .ok (new BookmarkCountDTO (type , count ));
170152 }
171153
172- @ Operation (
173- summary = "내가 북마크한 placeId 목록 조회" ,
174- description = """
175- 사용자가 북마크한 모든 placeId를 반환합니다.
176- 프론트엔드에서 북마크 아이콘 표시 여부를 판단할 때 사용합니다.
177-
178- ### 응답 예시
179- ```json
180- ["126508", "264636", "125406"]
181- ```
182-
183- ### 사용 예시
184- ```javascript
185- // 프론트엔드에서 활용
186- const bookmarkedIds = await fetchMyBookmarkedIds();
187- const isBookmarked = bookmarkedIds.includes(placeId);
188- ```
189- """ ,
190- tags = {"북마크 관리" }
191- )
192- @ GetMapping ("/bookmarks/my/ids" )
193- public ResponseEntity <List <String >> getMyBookmarkedPlaceIds (
194- @ Parameter (description = "북마크 타입 (선택사항)" )
195- @ RequestParam (required = false ) BookmarkType type ,
196-
197- Authentication authentication
198- ) {
199- String userEmail = authentication .getName ();
200-
201- List <String > placeIds ;
202- if (type != null ) {
203- placeIds = bookmarkService .getMyBookmarkedPlaceIdsByType (userEmail , type );
204- } else {
205- placeIds = bookmarkService .getMyBookmarkedPlaceIds (userEmail );
206- }
207-
208- return ResponseEntity .ok (placeIds );
209- }
210-
211154 private Sort createBookmarkSort (String arrange ) {
212155 return switch (arrange ) {
213- case "T" -> Sort .by (Sort .Direction .ASC , "place .title" ); // 제목 오름차순
156+ case "T" -> Sort .by (Sort .Direction .ASC , "contentId .title" ); // 제목 오름차순
214157 case "C" -> Sort .by (Sort .Direction .DESC , "createdAt" ); // 최신 북마크 순
215158 case "R" -> Sort .by (Sort .Direction .DESC , "place.averageRating" ) // 별점 높은 순
216159 .and (Sort .by (Sort .Direction .DESC , "createdAt" ));
0 commit comments