-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] #122 user repository에 누락된 조회 쿼리 코드 추가
- Loading branch information
Showing
2 changed files
with
75 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
main/src/main/java/org/sopt/makers/crew/main/entity/user/UserRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,20 @@ | ||
package org.sopt.makers.crew.main.entity.user; | ||
|
||
import java.util.Optional; | ||
import org.sopt.makers.crew.main.common.exception.UnAuthorizedException; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface UserRepository extends JpaRepository<User, Integer> { | ||
|
||
Optional<User> findByOrgId(Integer orgId); | ||
|
||
default User findByIdOrThrow(Integer userId) { | ||
return findById(userId) | ||
.orElseThrow(() -> new UnAuthorizedException()); | ||
} | ||
|
||
default User findByOrgIdOrThrow(Integer orgUserId) { | ||
return findByOrgId(orgUserId) | ||
.orElseThrow(() -> new UnAuthorizedException()); | ||
} | ||
} |