Skip to content

Commit

Permalink
๐Ÿ› fix: ์ข‹์•„์š” ์ค‘๋ณต ์ฒ˜๋ฆฌ
Browse files Browse the repository at this point in the history
  • Loading branch information
tmddus2 committed Aug 10, 2024
1 parent 0cd56cb commit 459b4bf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ public interface FilterLikeRepository extends JpaRepository<FilterLike, Long> {
+ "from FilterLike fl\n"
+ "where fl.filter = :filter")
int getLikes(@Param("filter") Filter filter);

boolean existsByFilterIdAndUserId(Long filterId, Long userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,17 @@ public IOSFilterDetailDto getFilterIOSDetail(Long filterId) {
}

public void likeFilter(Long userId, Long filterId) {
Filter filter = filterRepository.findById(filterId)
.orElseThrow(() -> CustomException.of(Error.NOT_FOUND_ERROR));
User user = userRepository.findById(userId)
.orElseThrow(() -> CustomException.of(Error.NOT_FOUND_ERROR));
if (!filterLikeRepository.existsByFilterIdAndUserId(filterId, userId)) {
Filter filter = filterRepository.findById(filterId)
.orElseThrow(() -> CustomException.of(Error.NOT_FOUND_ERROR));
User user = userRepository.findById(userId)
.orElseThrow(() -> CustomException.of(Error.NOT_FOUND_ERROR));

FilterLike like = FilterLike.builder()
.filter(filter).user(user).build();
FilterLike like = FilterLike.builder()
.filter(filter).user(user).build();

filterLikeRepository.save(like);
filterLikeRepository.save(like);
}
}

@Transactional
Expand Down

0 comments on commit 459b4bf

Please sign in to comment.