-
Notifications
You must be signed in to change notification settings - Fork 0
[FEAT] 서재 작품 메모&정보 조회 API 구현 #36
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
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
62401ae
[FIX] Memo 엔티티 nullable 옵션 추가
Kim-TaeUk ef9ede6
[FIX] Platform 엔티티 nullable 옵션 추가
Kim-TaeUk 344818d
[FIX] BaseTimeEntity nullable 옵션 추가 및 getter 추가
Kim-TaeUk f80fce0
[FEAT] 서재 작품 메모 및 정보 조회 API 구현
Kim-TaeUk b43e2ca
[FIX] 누락된 유저 authorization 로직 추가
Kim-TaeUk 01208e0
[RENAME] DTO 의미전달 잘 되도록 네이밍 변경
Kim-TaeUk 9ed2838
[RENAME] 컨트롤러와 서비스 단 메서드 의미전달 잘 되도록 네이밍 변경
Kim-TaeUk 814ed72
[REFACTOR] endpoint의 HTTP 응답처리 개선
Kim-TaeUk d198b18
[REFACTOR] Exception handling 명시적으로 변경
Kim-TaeUk 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,25 @@ | ||
| package com.wss.websoso.config; | ||
|
|
||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.EntityListeners; | ||
| import jakarta.persistence.MappedSuperclass; | ||
| import jakarta.persistence.PrePersist; | ||
| import org.springframework.data.annotation.CreatedDate; | ||
| import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import java.time.format.DateTimeFormatter; | ||
| import lombok.Getter; | ||
| import org.springframework.data.annotation.CreatedDate; | ||
| import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
|
||
| @MappedSuperclass | ||
| @EntityListeners(AuditingEntityListener.class) | ||
| @Getter | ||
| public abstract class BaseTimeEntity { | ||
| @CreatedDate // 생성 시각, 현재 시각으로 초기화 해줌! | ||
| private String createdDate; | ||
| @CreatedDate // 생성 시각, 현재 시각으로 초기화 해줌! | ||
| @Column(name = "created_date", nullable = false) | ||
| private String createdDate; | ||
|
|
||
| @PrePersist | ||
| public void onPrePersist() { | ||
| this.createdDate = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd a HH:mm")); | ||
| } | ||
| } | ||
| @PrePersist | ||
| public void onPrePersist() { | ||
| this.createdDate = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd a HH:mm")); | ||
| } | ||
| } |
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 |
|---|---|---|
| @@ -1,8 +1,13 @@ | ||
| package com.wss.websoso.memo; | ||
|
|
||
| import java.util.List; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import org.springframework.data.jpa.repository.Query; | ||
| import org.springframework.stereotype.Repository; | ||
|
|
||
| @Repository | ||
| public interface MemoRepository extends JpaRepository<Memo, Long> { | ||
| } | ||
|
|
||
| @Query(value = "SELECT m FROM Memo m WHERE m.userNovel.userNovelId = ?1") | ||
| List<Memo> findByUserNovelId(Long userNovelId); | ||
| } |
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
7 changes: 6 additions & 1 deletion
7
src/main/java/com/wss/websoso/platform/PlatformRepository.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 |
|---|---|---|
| @@ -1,8 +1,13 @@ | ||
| package com.wss.websoso.platform; | ||
|
|
||
| import java.util.List; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import org.springframework.data.jpa.repository.Query; | ||
| import org.springframework.stereotype.Repository; | ||
|
|
||
| @Repository | ||
| public interface PlatformRepository extends JpaRepository<Platform, Long> { | ||
| } | ||
|
|
||
| @Query(value = "SELECT p FROM Platform p WHERE p.userNovel.userNovelId = ?1 ") | ||
| List<Platform> findByUserNovelId(Long userNovelId); | ||
| } |
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
44 changes: 44 additions & 0 deletions
44
src/main/java/com/wss/websoso/userNovel/UserNovelMemoAndInfoGetResponse.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,44 @@ | ||
| package com.wss.websoso.userNovel; | ||
|
|
||
| import com.wss.websoso.config.ReadStatus; | ||
| import com.wss.websoso.memo.Memo; | ||
| import com.wss.websoso.platform.Platform; | ||
| import java.util.List; | ||
|
|
||
| public record UserNovelMemoAndInfoGetResponse( | ||
| List<UserNovelMemosGetResponse> memoList, | ||
| float userNovelRating, | ||
| ReadStatus userNovelReadStatus, | ||
| String userNovelReadStartDate, | ||
| String userNovelReadEndDate, | ||
| String userNovelDescription, | ||
| String userNovelGenre, | ||
| List<UserNovelPlatformsGetResponse> platformList | ||
| ) { | ||
|
|
||
| public static UserNovelMemoAndInfoGetResponse of(List<Memo> memos, UserNovel userNovel, List<Platform> platforms) { | ||
| List<UserNovelMemosGetResponse> memoList = memos.stream() | ||
| .map(memo -> new UserNovelMemosGetResponse( | ||
| memo.getMemoId(), | ||
| memo.getMemoContent(), | ||
| memo.getCreatedDate() | ||
| )).toList(); | ||
|
|
||
| List<UserNovelPlatformsGetResponse> platformList = platforms.stream() | ||
| .map(platform -> new UserNovelPlatformsGetResponse( | ||
| platform.getPlatformName(), | ||
| platform.getPlatformUrl() | ||
| )).toList(); | ||
|
|
||
| return new UserNovelMemoAndInfoGetResponse( | ||
| memoList, | ||
| userNovel.getUserNovelRating(), | ||
| userNovel.getUserNovelReadStatus(), | ||
| userNovel.getUserNovelReadStartDate(), | ||
| userNovel.getUserNovelReadEndDate(), | ||
| userNovel.getUserNovelDescription(), | ||
| userNovel.getUserNovelGenre(), | ||
| platformList | ||
| ); | ||
| } | ||
| } |
8 changes: 8 additions & 0 deletions
8
src/main/java/com/wss/websoso/userNovel/UserNovelMemosGetResponse.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,8 @@ | ||
| package com.wss.websoso.userNovel; | ||
|
|
||
| public record UserNovelMemosGetResponse( | ||
| Long memoId, | ||
| String memoContent, | ||
| String createdDate | ||
| ) { | ||
| } |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/wss/websoso/userNovel/UserNovelPlatformsGetResponse.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,7 @@ | ||
| package com.wss.websoso.userNovel; | ||
|
|
||
| public record UserNovelPlatformsGetResponse( | ||
| String platformName, | ||
| String platformUrl | ||
| ) { | ||
| } |
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
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.
Uh oh!
There was an error while loading. Please reload this page.