Skip to content
Merged

. #92

Show file tree
Hide file tree
Changes from all commits
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 @@ -30,7 +30,7 @@ Slice<Product> findCompletedProductsByCursor(@Param("cursorId") Long cursorId,
Page<Product> findByUserId(Long userId, Pageable pageable);

@Query(value = "SELECT p.product_id FROM product p JOIN user_behavior ub ON p.product_id = ub.product_id WHERE ub.user_id = :userId AND ub.behavior = :behavior ORDER BY RAND() LIMIT 1", nativeQuery = true)
Optional<Long> findRandomProductIdByUserIdAndBehavior(@Param("userId") Long userId, @Param("behavior") Behavior behavior);
Optional<Long> findRandomProductIdByUserIdAndBehavior(@Param("userId") Long userId, @Param("behavior") String behavior);

@Query("SELECT pl.product FROM ProductLike pl WHERE pl.user.id = :userId")
Page<Product> findLikedProductsByUserId(@Param("userId") Long userId, Pageable pageable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public UserBasedRecommendationResponseDto getUserBasedRecommendation(User user)

}

Long standardProductId = productRepository.findRandomProductIdByUserIdAndBehavior(userId,selectedBehavior)
Long standardProductId = productRepository.findRandomProductIdByUserIdAndBehavior(userId,selectedBehavior.name())
.orElseThrow(()-> new GeneralException(NO_USER_BEHAVIOR_EXISTED));
Product standardProduct = productRepository.findById(standardProductId).orElseThrow(()->new GeneralException(NO_RESULT));

Expand Down
Loading