88import com .memesphere .domain .collection .service .CollectionQueryService ;
99import com .memesphere .domain .search .service .SearchQueryService ;
1010import com .memesphere .domain .search .converter .SearchConverter ;
11+ import com .memesphere .global .jwt .CustomUserDetails ;
1112import com .memesphere .global .validation .annotation .CheckPage ;
1213import io .swagger .v3 .oas .annotations .Operation ;
1314import lombok .RequiredArgsConstructor ;
1415import org .springframework .data .domain .Page ;
16+ import org .springframework .security .core .annotation .AuthenticationPrincipal ;
17+ import org .springframework .security .core .userdetails .UserDetails ;
1518import org .springframework .web .bind .annotation .GetMapping ;
1619import org .springframework .web .bind .annotation .RequestParam ;
1720import org .springframework .web .bind .annotation .RestController ;
2023
2124@ RestController
2225@ RequiredArgsConstructor
23- //@RequestMapping("/")
2426public class SearchRestController {
2527 private final SearchQueryService searchQueryService ;
2628 private final CollectionQueryService collectionQueryService ;
@@ -31,12 +33,11 @@ public ApiResponse<SearchPageResponse> getSearchPage(
3133 @ RequestParam (name = "searchWord" ) String searchWord , // 검색어
3234 @ RequestParam (name = "viewType" , defaultValue = "GRID" ) ViewType viewType , // 뷰 타입 (grid 또는 list)
3335 @ RequestParam (name = "sortType" , defaultValue = "PRICE_CHANGE" ) SortType sortType , // 정렬 기준 (MKTCap, 24h Volume, Price)
34- @ CheckPage @ RequestParam (name = "page" ) Integer page // 페이지 번호
35- // @AuthenticationPrincipal UserDetails user // 현재 로그인한 유저
36+ @ CheckPage @ RequestParam (name = "page" ) Integer page , // 페이지 번호
37+ @ AuthenticationPrincipal CustomUserDetails userDetails // 현재 로그인한 유저
3638 ) {
3739 Integer pageNumber = page - 1 ;
38- // Long userId = user.getId();
39- Long userId = 1L ;
40+ Long userId = (userDetails == null ) ? null : userDetails .getUser ().getId ();
4041
4142 Page <MemeCoin > searchPage = searchQueryService .getSearchPage (searchWord , viewType , sortType , pageNumber );
4243 List <Long > userCollectionIds = collectionQueryService .getUserCollectionIds (userId );
0 commit comments