-
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.
* [BOOK-25]-feature: 독후감 목록 조회 * [BOOK-25]-refactor: 컨트롤러에서 반환 schema 오류 수정 * [BOOK-25]-refactor: 커멘트 수정 사항 반영 * [BOOK-25]-refactor: 커멘트 수정 사항 반영
- Loading branch information
Showing
18 changed files
with
242 additions
and
33 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
2 changes: 2 additions & 0 deletions
2
src/main/java/goorm/unit/booklog/domain/book/domain/BookRepository.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
32 changes: 17 additions & 15 deletions
32
src/main/java/goorm/unit/booklog/domain/book/infrastructure/BookRepositoryImpl.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,30 +1,32 @@ | ||
package goorm.unit.booklog.domain.book.infrastructure; | ||
|
||
import goorm.unit.booklog.domain.book.domain.Book; | ||
import goorm.unit.booklog.domain.book.domain.BookRepository; | ||
import goorm.unit.booklog.domain.user.domain.User; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import goorm.unit.booklog.domain.book.domain.BookRepository; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class BookRepositoryImpl implements BookRepository { | ||
private final JpaBookRepository jpaBookRepository; | ||
public class BookRepositoryImpl implements BookRepository{ | ||
private final JpaBookRepository jpaBookRepository; | ||
@Override | ||
public Book save(Book book) { | ||
return jpaBookRepository.save(book); | ||
} | ||
|
||
@Override | ||
public Book save(Book book) { | ||
return jpaBookRepository.save(book); | ||
} | ||
@Override | ||
public Optional<Book> findById(Long id) { | ||
return jpaBookRepository.findById(id); | ||
} | ||
|
||
@Override | ||
public Optional<Book> findById(Long id) { | ||
return jpaBookRepository.findById(id); | ||
} | ||
@Override | ||
public Optional<Book> findByTitleAndAuthor(String title, String author) { | ||
return jpaBookRepository.findByTitleAndAuthor(title, author); | ||
} | ||
|
||
@Override | ||
public Optional<Book> findByTitleAndAuthor(String title, String author){ | ||
return jpaBookRepository.findByTitleAndAuthor(title,author); | ||
}; | ||
} |
1 change: 0 additions & 1 deletion
1
src/main/java/goorm/unit/booklog/domain/book/infrastructure/JpaBookRepository.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
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
22 changes: 22 additions & 0 deletions
22
src/main/java/goorm/unit/booklog/domain/book/presentation/exception/BookExceptionCode.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,22 @@ | ||
package goorm.unit.booklog.domain.book.presentation.exception; | ||
|
||
import goorm.unit.booklog.common.exception.ExceptionCode; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import org.springframework.http.HttpStatus; | ||
|
||
import static org.springframework.http.HttpStatus.NOT_FOUND; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum BookExceptionCode implements ExceptionCode { | ||
BOOK_NOT_FOUND(NOT_FOUND, "해당 도서가 존재하지 않습니다."),; | ||
|
||
private final HttpStatus status; | ||
private final String message; | ||
|
||
@Override | ||
public String getCode() { | ||
return this.name(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...ain/java/goorm/unit/booklog/domain/book/presentation/exception/BookNotFoundException.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,11 @@ | ||
package goorm.unit.booklog.domain.book.presentation.exception; | ||
|
||
import goorm.unit.booklog.common.exception.CustomException; | ||
|
||
import static goorm.unit.booklog.domain.book.presentation.exception.BookExceptionCode.BOOK_NOT_FOUND; | ||
|
||
public class BookNotFoundException extends CustomException { | ||
public BookNotFoundException() { | ||
super(BOOK_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
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
40 changes: 40 additions & 0 deletions
40
src/main/java/goorm/unit/booklog/domain/book/presentation/response/UserBookListResponse.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,40 @@ | ||
package goorm.unit.booklog.domain.book.presentation.response; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Builder; | ||
|
||
import java.util.List; | ||
|
||
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; | ||
|
||
@Builder | ||
public record UserBookListResponse( | ||
@Schema(description = "유저 아이디", example = "id1234", requiredMode = REQUIRED) | ||
String userId, | ||
|
||
@Schema(description = "유저 이름", example = "홍길동", requiredMode = REQUIRED) | ||
String userName, | ||
|
||
@Schema(description = "읽은 책 수", example = "1", requiredMode = REQUIRED) | ||
Integer bookCount, | ||
|
||
@Schema(description = "작성한 독후감 수", example = "1", requiredMode = REQUIRED) | ||
Integer reviewCount, | ||
|
||
@Schema( | ||
description = "읽은 책 목록", | ||
example = "[{\"id\": 1, \"title\": \"스프링 부트와 AWS로 혼자 구현하는 웹 서비스\", \"author\": \"이한음\", \"description\": \"스프링 부트와 AWS로 혼자 구현하는 웹 서비스\", \"file\": {\"id\": 1, \"logicalName\": \"example.jpg\", \"physicalPath\": \"https://example-bucket.ncp.com/files/example.jpg\"}}]", | ||
requiredMode = REQUIRED | ||
) | ||
List<BookResponse> bookResponses | ||
) { | ||
public static UserBookListResponse of(String userId, String userName, Integer bookCount, Integer reviewCount, List<BookResponse> bookResponses) { | ||
return UserBookListResponse.builder() | ||
.userId(userId) | ||
.userName(userName) | ||
.bookCount(bookCount) | ||
.reviewCount(reviewCount) | ||
.bookResponses(bookResponses) | ||
.build(); | ||
} | ||
} |
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
5 changes: 5 additions & 0 deletions
5
src/main/java/goorm/unit/booklog/domain/review/domain/ReviewRepository.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,9 +1,14 @@ | ||
package goorm.unit.booklog.domain.review.domain; | ||
|
||
import goorm.unit.booklog.domain.book.domain.Book; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public interface ReviewRepository { | ||
Review save(Review review); | ||
|
||
Optional<Review> findById(Long id); | ||
|
||
List<Review> findAllByBook(Book book); | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/goorm/unit/booklog/domain/review/infrastructure/JpaReviewRepository.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,11 @@ | ||
package goorm.unit.booklog.domain.review.infrastructure; | ||
|
||
import goorm.unit.booklog.domain.book.domain.Book; | ||
import goorm.unit.booklog.domain.review.domain.Review; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.List; | ||
|
||
public interface JpaReviewRepository extends JpaRepository<Review,Long> { | ||
List<Review> findAllByBook(Book book); | ||
} |
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
Oops, something went wrong.