-
Notifications
You must be signed in to change notification settings - Fork 0
[refactor] 기록장 조회 api 수정 #66
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
Changes from all commits
301fdd6
f8daee6
183f5fd
565cd55
93e4aac
65c4121
f893892
11b8dfa
1ee0223
19e2b5b
13dffdf
3b26133
09d3027
3278def
34fb5cc
256661d
4d93575
d0317c3
7bcd7b3
66bc8ee
68cdb0e
6af0a96
23f49e2
631f0a0
cf958bf
96fee95
2b825e7
a9edaf4
4dcff14
eb31143
f6b8e43
88f021c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,8 +28,8 @@ public class FeedJpaEntity extends PostJpaEntity { | |
| private BookJpaEntity bookJpaEntity; | ||
|
|
||
| @Builder | ||
| public FeedJpaEntity(String content, UserJpaEntity userJpaEntity, Boolean isPublic, int reportCount, BookJpaEntity bookJpaEntity) { | ||
| super(content, userJpaEntity); | ||
| public FeedJpaEntity(String content, Integer likeCount, Integer commentCount, UserJpaEntity userJpaEntity, Boolean isPublic, int reportCount, BookJpaEntity bookJpaEntity) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍🏻👍🏻 |
||
| super(content, likeCount, commentCount, userJpaEntity); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LGTM |
||
| this.isPublic = isPublic; | ||
| this.reportCount = reportCount; | ||
| this.bookJpaEntity = bookJpaEntity; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,12 +23,18 @@ public abstract class PostJpaEntity extends BaseJpaEntity { | |
| @Column(length = 6100, nullable = false) | ||
| private String content; | ||
|
|
||
| private Integer likeCount = 0; | ||
|
|
||
| private Integer commentCount = 0; | ||
|
Comment on lines
+26
to
+28
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 좋습니다! 이제 저희가 관련 C,U,D 할때 해당 데이터를 잘 업데이트 해줘야 하니 이 점 유의하면서 개발 진행해야할 것 같네요 |
||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "user_id", nullable = false) | ||
| private UserJpaEntity userJpaEntity; | ||
|
|
||
| public PostJpaEntity(String content, UserJpaEntity userJpaEntity) { | ||
| public PostJpaEntity(String content, Integer likeCount, Integer commentCount, UserJpaEntity userJpaEntity) { | ||
| this.content = content; | ||
| this.likeCount = likeCount; | ||
| this.commentCount = commentCount; | ||
| this.userJpaEntity = userJpaEntity; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,6 @@ | |
| import konkuk.thip.common.dto.BaseResponse; | ||
| import konkuk.thip.common.security.annotation.UserId; | ||
| import konkuk.thip.record.adapter.in.web.response.RecordSearchResponse; | ||
| import konkuk.thip.record.application.port.in.dto.RecordSearchQuery; | ||
| import konkuk.thip.record.application.port.in.dto.RecordSearchUseCase; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
|
|
@@ -20,24 +19,15 @@ public class RecordQueryController { | |
| @GetMapping("/rooms/{roomId}/posts") | ||
| public BaseResponse<RecordSearchResponse> viewRecordList( | ||
| @PathVariable final Long roomId, | ||
| @RequestParam final String type, | ||
| @RequestParam final String sort, | ||
| @RequestParam(required = false) final String type, | ||
| @RequestParam(required = false) final String sort, | ||
| @RequestParam(required = false) final Integer pageStart, | ||
| @RequestParam(required = false) final Integer pageEnd, | ||
| @RequestParam final Boolean isOverview, | ||
| @RequestParam final Integer pageNum, | ||
| @UserId final Long userId | ||
| ) { | ||
| return BaseResponse.ok(recordSearchUseCase.search( | ||
| RecordSearchQuery.builder() | ||
| .roomId(roomId) | ||
| .type(type) | ||
| .sort(sort) | ||
| .pageStart(pageStart) | ||
| .pageEnd(pageEnd) | ||
| .pageNum(pageNum) | ||
| .userId(userId) | ||
| .build() | ||
| )); | ||
| return BaseResponse.ok(recordSearchUseCase.search(roomId, type, sort, pageStart, pageEnd, isOverview, pageNum, userId)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 옷 RecordSearchQuery는 왜 빼신거에요?? 단순궁금
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 현재 pageNum과 같은 변수에서 유효성 검증 후 값을 직접 조정하는 로직이 있어서, 굳이 불변객체로 DTO를 하나 더 두지 않아도 된다고 판단했습니다! |
||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,39 +1,21 @@ | ||
| package konkuk.thip.record.adapter.out.persistence; | ||
|
|
||
| import konkuk.thip.record.adapter.out.mapper.RecordMapper; | ||
| import konkuk.thip.record.application.port.in.dto.RecordSearchResult; | ||
| import konkuk.thip.record.adapter.in.web.response.RecordSearchResponse; | ||
| import konkuk.thip.record.application.port.out.RecordQueryPort; | ||
| import konkuk.thip.record.domain.Record; | ||
| import konkuk.thip.vote.adapter.out.mapper.VoteMapper; | ||
| import konkuk.thip.vote.adapter.out.persistence.VoteJpaRepository; | ||
| import konkuk.thip.vote.domain.Vote; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.data.domain.Page; | ||
| import org.springframework.data.domain.Pageable; | ||
| import org.springframework.stereotype.Repository; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Repository | ||
| @RequiredArgsConstructor | ||
| public class RecordQueryPersistenceAdapter implements RecordQueryPort { | ||
|
|
||
| private final RecordJpaRepository recordJpaRepository; | ||
| private final VoteJpaRepository voteJpaRepository; | ||
| private final RecordMapper recordMapper; | ||
| private final VoteMapper voteMapper; | ||
|
|
||
| private static final Integer PAGE_SIZE = 10; | ||
|
|
||
| @Override | ||
| public RecordSearchResult findRecordsByRoom(Long roomId, String type, Integer pageStart, Integer pageEnd, Long userId, Integer pageNum) { | ||
| List<Record> records = recordJpaRepository.findRecordsByRoom(roomId, type, pageStart, pageEnd, userId).stream() | ||
| .map(recordMapper::toDomainEntity) | ||
| .toList(); | ||
|
|
||
| List<Vote> votes = voteJpaRepository.findVotesByRoom(roomId, type, pageStart, pageEnd, userId).stream() | ||
| .map(voteMapper::toDomainEntity) | ||
| .toList(); | ||
|
|
||
| return RecordSearchResult.of(records, votes); | ||
| public Page<RecordSearchResponse.RecordSearchResult> findRecordsByRoom(Long roomId, String type, Integer pageStart, Integer pageEnd, Boolean isOverview, Long userId, Pageable pageable) { | ||
| return recordJpaRepository.findRecordsByRoom(roomId, type, pageStart, pageEnd, isOverview, userId, pageable); | ||
| } | ||
| } | ||
|
|
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.
LGTM