-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor - #9 이름 및 exception 처리 코드 위치 변경
- Loading branch information
Showing
5 changed files
with
16 additions
and
12 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
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
6 changes: 6 additions & 0 deletions
6
src/main/java/sopt/org/HMH/domain/dayChallenge/repository/DayChallengeRepository.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,7 +1,13 @@ | ||
package sopt.org.HMH.domain.dayChallenge.repository; | ||
|
||
import jakarta.persistence.EntityNotFoundException; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import sopt.org.HMH.domain.dayChallenge.domain.DayChallenge; | ||
import sopt.org.HMH.domain.user.exception.UserError; | ||
|
||
public interface DayChallengeRepository extends JpaRepository<DayChallenge, Long> { | ||
|
||
default DayChallenge findByIdOrThrowException(Long dayChallengeId) { | ||
return findById(dayChallengeId).orElseThrow(() -> new EntityNotFoundException(UserError.USER_NOT_FOUND.getErrorMessage())); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/sopt/org/HMH/domain/user/repository/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,7 +1,13 @@ | ||
package sopt.org.HMH.domain.user.repository; | ||
|
||
import jakarta.persistence.EntityNotFoundException; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import sopt.org.HMH.domain.user.User; | ||
import sopt.org.HMH.domain.user.exception.UserError; | ||
|
||
public interface UserRepository extends JpaRepository<User, Long> { | ||
|
||
default User findByIdOrThrowException(Long userId) { | ||
return findById(userId).orElseThrow(() -> new EntityNotFoundException(UserError.USER_NOT_FOUND.getErrorMessage())); | ||
} | ||
} |
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