-
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.
- Loading branch information
Showing
7 changed files
with
96 additions
and
7 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
26 changes: 26 additions & 0 deletions
26
src/main/java/cotato/bookitlist/post/dto/response/PostListResponse.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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package cotato.bookitlist.post.dto.response; | ||
|
||
import cotato.bookitlist.post.domain.Post; | ||
import cotato.bookitlist.post.dto.PostDto; | ||
import org.springframework.data.domain.Page; | ||
|
||
import java.util.List; | ||
|
||
public record PostListResponse( | ||
int totalResults, | ||
int totalPages, | ||
int startIndex, | ||
int itemsPerPage, | ||
List<PostDto> postList | ||
) { | ||
|
||
public static PostListResponse from(Page<Post> page) { | ||
return new PostListResponse( | ||
(int) page.getTotalElements(), | ||
page.getTotalPages(), | ||
page.getNumber(), | ||
page.getSize(), | ||
page.stream().map(PostDto::from).toList() | ||
); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
src/main/java/cotato/bookitlist/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,7 +1,10 @@ | ||
package cotato.bookitlist.post.repository; | ||
|
||
import cotato.bookitlist.post.domain.Post; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface PostRepository extends JpaRepository<Post, Long> { | ||
Page<Post> findByBook_Isbn13(String isbn13, 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,11 @@ VALUES ('[email protected]', 'test', 'test', 'KAKAO', 0, false, CURRENT_TIMESTAMP, | |
|
||
INSERT INTO post (member_id, book_id, title, content, like_count, view_count, deleted) | ||
VALUES (1, 1, 'postTitle', 'postContent', 0, 0, false), | ||
(2, 1, 'postTitle', 'postContent', 0, 0, false); | ||
(2, 1, 'postTitle1', 'Content', 0, 0, false), | ||
(2, 1, 'postTitle2', '제목', 0, 0, false), | ||
(2, 1, 'postTitle3', 'post', 0, 0, false), | ||
(2, 2, 'posTitle', 'ptent', 0, 0, false), | ||
(2, 2, 'positle', 'postent', 0, 0, false); | ||
|
||
INSERT INTO review (member_id, book_id, content, like_count, view_count, deleted) | ||
VALUES (1, 1, 'reviewContent', 0, 0, false), | ||
|