diff --git a/src/main/java/team7/inplace/user/application/UserService.java b/src/main/java/team7/inplace/user/application/UserService.java index a17c53a4..ca4c315f 100644 --- a/src/main/java/team7/inplace/user/application/UserService.java +++ b/src/main/java/team7/inplace/user/application/UserService.java @@ -36,9 +36,8 @@ public UserCommand.Info getUserByUsername(String username) { } @Transactional(readOnly = true) - public List getInfluencerIdsByUsername(String username) { - List likes = userFavoriteInfluencerRepository - .findByUser(userRepository.findByUsername(username).orElseThrow()); + public List getInfluencerIdsByUsername(Long userId) { + List likes = userFavoriteInfluencerRepository.findByUserId(userId); return likes.stream().map(UserFavoriteInfluencer::getInfluencer).map(Influencer::getId).toList(); } } diff --git a/src/main/java/team7/inplace/userFavoriteInfluencer/persistent/UserFavoriteInfluencerRepository.java b/src/main/java/team7/inplace/userFavoriteInfluencer/persistent/UserFavoriteInfluencerRepository.java index 04997d26..85a36861 100644 --- a/src/main/java/team7/inplace/userFavoriteInfluencer/persistent/UserFavoriteInfluencerRepository.java +++ b/src/main/java/team7/inplace/userFavoriteInfluencer/persistent/UserFavoriteInfluencerRepository.java @@ -7,7 +7,5 @@ import java.util.List; public interface UserFavoriteInfluencerRepository extends JpaRepository { - List findByUser(User user); - - UserFavoriteInfluencer save(UserFavoriteInfluencer favorite); + List findByUserId(Long userId); } diff --git a/src/main/java/team7/inplace/video/application/VideoService.java b/src/main/java/team7/inplace/video/application/VideoService.java index 60f72150..1d4b4647 100644 --- a/src/main/java/team7/inplace/video/application/VideoService.java +++ b/src/main/java/team7/inplace/video/application/VideoService.java @@ -5,6 +5,7 @@ import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; +import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; import team7.inplace.global.exception.InplaceException; import team7.inplace.global.exception.code.AuthorizationErrorCode; @@ -57,13 +58,13 @@ public Page getAllVideosDesc(Pageable pageable) { public Page getVideosByMyInfluencer(Pageable pageable){ // User 정보를 쿠키에서 추출 - String username = AuthorizationUtil.getUsername(); + Long userId = AuthorizationUtil.getUserId(); // 토큰 정보에 대한 검증 - if(!StringUtils.hasText(username)) { + if(ObjectUtils.isEmpty(userId)) { throw InplaceException.of(AuthorizationErrorCode.TOKEN_IS_EMPTY); } // 유저 정보를 이용하여 유저가 좋아요를 누른 인플루언서 id 리스트를 조회 - List influencerIds = userService.getInfluencerIdsByUsername(username); + List influencerIds = userService.getInfluencerIdsByUsername(userId); // 인플루언서 id 리스트를 이용하여 해당 인플루언서의 비디오들을 조회 Page