-
Notifications
You must be signed in to change notification settings - Fork 0
[FEAT] 읽은 책 책장, 책 상세 조회 구현 #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -22,3 +22,4 @@ public class BookSearchRequestDTO { | |
| private Integer size = 10; // 한 페이지당 개수 (기본값 10, 최대 100) | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or 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
46 changes: 46 additions & 0 deletions
46
src/main/java/com/moongeul/backend/api/bookshelf/controller/DoneReadBookshelfController.java
This file contains hidden or 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,46 @@ | ||
| package com.moongeul.backend.api.bookshelf.controller; | ||
|
|
||
| import com.moongeul.backend.api.bookshelf.dto.DoneReadBookshelfResponseDTO; | ||
| import com.moongeul.backend.api.bookshelf.service.DoneReadBookshelfService; | ||
| import com.moongeul.backend.common.response.ApiResponse; | ||
| import com.moongeul.backend.common.response.SuccessStatus; | ||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||
| import jakarta.validation.constraints.Min; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
| import org.springframework.security.core.userdetails.UserDetails; | ||
| import org.springframework.validation.annotation.Validated; | ||
| import org.springframework.web.bind.annotation.*; | ||
|
|
||
| @Tag(name = "DoneReadBookshelf", description = "읽은 책장 관련 API 입니다.") | ||
| @RestController | ||
| @RequiredArgsConstructor | ||
| @RequestMapping("/api/v2/bookshelf/done-read") | ||
| @Validated | ||
| public class DoneReadBookshelfController { | ||
|
|
||
| private final DoneReadBookshelfService doneReadBookshelfService; | ||
|
|
||
| @Operation( | ||
| summary = "읽은 책장 전체 조회 API", | ||
| description = "인증된 사용자의 읽은 책장 목록을 최신순으로 조회합니다. (페이지와 사이즈는 1부터 시작합니다)" | ||
| ) | ||
| @ApiResponses({ | ||
| @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200", description = "읽은 책장 조회 성공"), | ||
| @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "400", description = "잘못된 요청 파라미터"), | ||
| @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "404", description = "사용자를 찾을 수 없습니다.") | ||
| }) | ||
| @GetMapping | ||
| public ResponseEntity<ApiResponse<DoneReadBookshelfResponseDTO>> getDoneReadBooks( | ||
| @AuthenticationPrincipal UserDetails userDetails, | ||
| @RequestParam(required = false, defaultValue = "1") @Min(value = 1, message = "페이지는 1 이상이어야 합니다.") Integer page, | ||
| @RequestParam(required = false, defaultValue = "10") @Min(value = 1, message = "한 페이지당 개수는 1 이상이어야 합니다.") Integer size) { | ||
|
|
||
| DoneReadBookshelfResponseDTO doneReadBookshelfResponseDTO = doneReadBookshelfService.getDoneReadBooks(userDetails.getUsername(), page, size); | ||
| return ApiResponse.success(SuccessStatus.GET_DONE_READ_BOOKS_SUCCESS, doneReadBookshelfResponseDTO); | ||
| } | ||
| } | ||
|
|
This file contains hidden or 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/com/moongeul/backend/api/bookshelf/dto/DoneReadBookshelfItemDTO.java
This file contains hidden or 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 com.moongeul.backend.api.bookshelf.dto; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Getter | ||
| @Builder | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| public class DoneReadBookshelfItemDTO { | ||
| private Long articleId; // 게시글 ID | ||
| private String isbn; // ISBN | ||
| private String title; // 책 제목 | ||
| private String author; // 저자 | ||
| private String bookImage; // 표지 이미지 | ||
| private String publisher; // 출판사 | ||
| private String description; // 책 소개 | ||
| private String pubdate; // 출판연도 | ||
| private Double ratingAverage; // 별점 평균 | ||
| private Integer ratingCount; // 별점 개수 | ||
| private Float weight; // 두께 | ||
| private Float height; // 높이 | ||
| } | ||
|
|
||
22 changes: 22 additions & 0 deletions
22
src/main/java/com/moongeul/backend/api/bookshelf/dto/DoneReadBookshelfResponseDTO.java
This file contains hidden or 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,22 @@ | ||
| package com.moongeul.backend.api.bookshelf.dto; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Getter | ||
| @Builder | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| public class DoneReadBookshelfResponseDTO { | ||
| private Integer total; // 전체 개수 | ||
| private Integer page; // 현재 페이지 | ||
| private Integer size; // 페이지당 개수 | ||
| private Integer totalPages; // 전체 페이지 수 | ||
| private Boolean isLast; // 마지막 페이지 여부 | ||
| private List<DoneReadBookshelfItemDTO> books; // 읽은 책 목록 | ||
| } | ||
|
|
23 changes: 23 additions & 0 deletions
23
src/main/java/com/moongeul/backend/api/bookshelf/dto/WishReadBookshelfResponseDTO.java
This file contains hidden or 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,23 @@ | ||
| package com.moongeul.backend.api.bookshelf.dto; | ||
|
|
||
| import com.moongeul.backend.api.book.dto.BookDTO; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Getter | ||
| @Builder | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| public class WishReadBookshelfResponseDTO { | ||
| private Integer total; // 전체 개수 | ||
| private Integer page; // 현재 페이지 | ||
| private Integer size; // 페이지당 개수 | ||
| private Integer totalPages; // 전체 페이지 수 | ||
| private Boolean isLast; // 마지막 페이지 여부 | ||
| private List<BookDTO> books; // 읽고 싶은 책 목록 | ||
| } | ||
|
|
39 changes: 39 additions & 0 deletions
39
src/main/java/com/moongeul/backend/api/bookshelf/entity/DoneReadBookshelf.java
This file contains hidden or 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,39 @@ | ||
| package com.moongeul.backend.api.bookshelf.entity; | ||
|
|
||
| import com.moongeul.backend.api.member.entity.Member; | ||
| import com.moongeul.backend.api.post.entity.Post; | ||
| import com.moongeul.backend.common.entity.BaseTimeEntity; | ||
| import jakarta.persistence.*; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Entity | ||
| @Getter | ||
| @Builder | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @Table(name = "done_read_bookshelf") | ||
| public class DoneReadBookshelf extends BaseTimeEntity { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| @Column(name = "done_bookshelf_id") | ||
| private Long doneBookshelfId; | ||
|
|
||
| @Column(name = "weight") | ||
| private Float weight; // 도서 길이 기반 두께 | ||
|
|
||
| @Column(name = "height") | ||
| private Float height; // 별점 기반 높낮이 | ||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "article_id", nullable = false) | ||
| private Post article; // 게시글 | ||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "member_id", nullable = false) | ||
| private Member member; // 회원 | ||
| } | ||
|
|
This file contains hidden or 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
15 changes: 15 additions & 0 deletions
15
src/main/java/com/moongeul/backend/api/bookshelf/repository/DoneReadBookshelfRepository.java
This file contains hidden or 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,15 @@ | ||
| package com.moongeul.backend.api.bookshelf.repository; | ||
|
|
||
| import com.moongeul.backend.api.bookshelf.entity.DoneReadBookshelf; | ||
| import com.moongeul.backend.api.member.entity.Member; | ||
| import org.springframework.data.domain.Page; | ||
| import org.springframework.data.domain.Pageable; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import org.springframework.data.jpa.repository.Query; | ||
| import org.springframework.data.repository.query.Param; | ||
|
|
||
| public interface DoneReadBookshelfRepository extends JpaRepository<DoneReadBookshelf, Long> { | ||
| @Query("SELECT d FROM DoneReadBookshelf d WHERE d.member = :member ORDER BY d.createdAt DESC") | ||
| Page<DoneReadBookshelf> findByMemberOrderByCreatedAtDesc(@Param("member") Member member, Pageable pageable); | ||
| } | ||
|
|
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
해당 DTO = 읽은 책 책장에 표시되는 책 정보에 대한 DTO로 이해했는데 맞을까요?
맞다면, 읽은 책 책장 페이지에서 필요한 정보는 [도서명, 별점, 두께, 높이, 게시글 ID, {해당 도서로 작성된 게시글 개수}] 인데 다른 정보도 같이 보내주는 이유가 무엇인지 여쭤봐도 될까요?