-
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.
Merge pull request #76 from Leets-Official/feature-#75
#75 Feat: 15개씩 게시글 조회하는 기능 추가
- Loading branch information
Showing
4 changed files
with
54 additions
and
17 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
9 changes: 9 additions & 0 deletions
9
src/main/java/leets/weeth/domain/post/repository/PostRepository.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,13 +1,22 @@ | ||
package leets.weeth.domain.post.repository; | ||
|
||
import leets.weeth.domain.post.entity.Post; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.domain.Sort; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public interface PostRepository extends JpaRepository<Post, Long> { | ||
ArrayList<Post> findAll(); | ||
List<Post> findByUserId(Long userId, Sort sort); | ||
|
||
@Query("SELECT MAX(p.id) FROM Post p") | ||
Long findMaxPostId(); | ||
|
||
@Query("SELECT p FROM Post p WHERE p.id < :maxPostId ORDER BY p.id DESC") | ||
List<Post> findRecentPosts(@Param("maxPostId") Long maxPostId, Pageable pageable); | ||
|
||
} |
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