-
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.
- Loading branch information
Showing
3 changed files
with
29 additions
and
0 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
10 changes: 10 additions & 0 deletions
10
src/main/java/com/pickple/server/api/notice/repository/NoticeRepository.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,10 +1,20 @@ | ||
package com.pickple.server.api.notice.repository; | ||
|
||
import com.pickple.server.api.notice.domain.Notice; | ||
import com.pickple.server.global.exception.CustomException; | ||
import com.pickple.server.global.response.enums.ErrorCode; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface NoticeRepository extends JpaRepository<Notice, Long> { | ||
|
||
List<Notice> findNoticeByMoimIdOrderByCreatedAtDesc(Long moimId); | ||
|
||
Optional<Notice> findNoticeById(Long id); | ||
|
||
default Notice findNoticeByIdOrThrow(Long id) { | ||
return findNoticeById(id) | ||
.orElseThrow(() -> new CustomException(ErrorCode.NOTICE_NOT_FOUND)); | ||
} | ||
} |
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