Skip to content
Merged
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 @@ -3,12 +3,14 @@
import com.ureca.uplait.domain.plan.entity.Plan;
import com.ureca.uplait.domain.user.entity.Bookmark;
import java.util.Optional;

import com.ureca.uplait.domain.user.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;

public interface BookmarkRepository extends JpaRepository<Bookmark, Long>,
CustomBookmarkRepository {

boolean existsBookmarkByPlanId(Long planId);
boolean existsBookmarkByPlanIdAndUser(Long planId, User user);

Optional<Bookmark> findByUserIdAndPlanId(Long userId, Long planId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public BookmarkListResponse getBookmarks(User user, PlanType planType, int size,

@Transactional
public CreateBookmarkResponse createBookmark(User user, Long planId) {
if (bookmarkRepository.existsBookmarkByPlanId(planId)) {
if (bookmarkRepository.existsBookmarkByPlanIdAndUser(planId, user)) {
throw new GlobalException(DUPLICATED_BOOKMARK);
}

Expand Down
Loading