Skip to content

Commit

Permalink
fix: user id 검증 로직 추가
Browse files Browse the repository at this point in the history
fix: user id 검증 로직 추가
  • Loading branch information
yj-leez authored Dec 27, 2023
2 parents 0ac81fb + 89a2da3 commit 589b75f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,10 @@
public interface HobbyRepository extends JpaRepository<Hobby, Long> {

Hobby findByUser(User user);

// @Query("SELECT CASE WHEN COUNT(h) > 0 THEN true ELSE false END FROM Hobby h WHERE h.user = :user")
// boolean existsHobbyByUser(@Param("user") User user);
boolean existsByUser(User user);


}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public void setUserHobby(User user, HobbyRequestDto requestDto){
}

public void setUserHobbyRe(User user, HobbyRequestDtoRe dto) {
if(hobbyRepository.existsByUser(user)) throw new IllegalArgumentException();

Hobby hobby = new Hobby(user, dto.getStrings());
hobbyRepository.save(hobby);
}
Expand Down

0 comments on commit 589b75f

Please sign in to comment.