-
Notifications
You must be signed in to change notification settings - Fork 0
[feat] 기록장 조회 api 구현 #58
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
5025df1
c6ee6b7
407951f
c939462
713c70c
cc22862
45d2b6f
9624ef7
6e3fbc2
1706950
9774c28
a35794d
71c37a9
8157217
773213a
39e2d2e
6b2575c
cbe762a
9067ded
2cda225
332db3e
512c521
9771981
cfdc977
9dd6389
3ca033b
4db47e5
0c97b1b
9da1c6a
0dd327b
7917128
968b9e3
cba1cee
7ef7cca
16c8996
e5cfb46
7612165
69c6881
2f4745e
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 |
|---|---|---|
|
|
@@ -2,4 +2,6 @@ | |
|
|
||
| public interface CommentQueryPort { | ||
|
|
||
| int countByPostId(Long postId); | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -80,22 +80,27 @@ public enum ErrorCode implements ResponseCode { | |||||
| INVALID_VOTE_PAGE_RANGE(HttpStatus.BAD_REQUEST, 110002, "VOTE의 page 값이 유효하지 않습니다."), | ||||||
|
|
||||||
| /** | ||||||
| * 120000 : record error | ||||||
| * 120000 : voteItem error | ||||||
| */ | ||||||
| RECORD_NOT_FOUND(HttpStatus.NOT_FOUND, 120000, "존재하지 않는 RECORD 입니다."), | ||||||
| RECORD_CANNOT_BE_OVERVIEW(HttpStatus.BAD_REQUEST, 120001, "총평이 될 수 없는 RECORD 입니다."), | ||||||
| INVALID_RECORD_PAGE_RANGE(HttpStatus.BAD_REQUEST, 120002, "RECORD의 page 값이 유효하지 않습니다."), | ||||||
| VOTE_ITEM_NOT_FOUND(HttpStatus.NOT_FOUND, 120000, "투표는 존재하지만 투표항목이 비어있습니다."), | ||||||
|
|
||||||
| /** | ||||||
| * 130000 : record error | ||||||
| */ | ||||||
| RECORD_NOT_FOUND(HttpStatus.NOT_FOUND, 130000, "존재하지 않는 RECORD 입니다."), | ||||||
| RECORD_CANNOT_BE_OVERVIEW(HttpStatus.BAD_REQUEST, 130001, "총평이 될 수 없는 RECORD 입니다."), | ||||||
| INVALID_RECORD_PAGE_RANGE(HttpStatus.BAD_REQUEST, 130002, "RECORD의 page 값이 유효하지 않습니다."), | ||||||
| RECORD_CANNOT_WRITE_IN_EXPIRED_ROOM(HttpStatus.BAD_REQUEST, 120003, "만료된 방에는 기록을 남길 수 없습니다."), | ||||||
|
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. 에러 코드 번호 불일치를 수정하세요.
- RECORD_CANNOT_WRITE_IN_EXPIRED_ROOM(HttpStatus.BAD_REQUEST, 120003, "만료된 방에는 기록을 남길 수 없습니다."),
+ RECORD_CANNOT_WRITE_IN_EXPIRED_ROOM(HttpStatus.BAD_REQUEST, 130003, "만료된 방에는 기록을 남길 수 없습니다."),📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
|
|
||||||
| /** | ||||||
| * 130000 : userRoom error | ||||||
| * 140000 : userRoom error | ||||||
| */ | ||||||
| USER_ROOM_NOT_FOUND(HttpStatus.NOT_FOUND, 130000, "존재하지 않는 USER_ROOM (방과 사용자 관계) 입니다."), | ||||||
| USER_ROOM_NOT_FOUND(HttpStatus.NOT_FOUND, 140000, "존재하지 않는 USER_ROOM (방과 사용자 관계) 입니다."), | ||||||
|
|
||||||
| /** | ||||||
| * 140000 : Category error | ||||||
| * 150000 : Category error | ||||||
| */ | ||||||
| CATEGORY_NOT_FOUND(HttpStatus.NOT_FOUND, 140000, "존재하지 않는 CATEGORY 입니다.") | ||||||
| CATEGORY_NOT_FOUND(HttpStatus.NOT_FOUND, 150000, "존재하지 않는 CATEGORY 입니다.") | ||||||
|
Comment on lines
+90
to
+103
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. 💡 Verification agent 🧩 Analysis chain기존 에러 코드 변경의 호환성을 확인하세요. RECORD, USER_ROOM, CATEGORY 관련 에러 코드들이 다른 범위로 이동되었습니다. 이미 사용 중인 클라이언트가 있다면 호환성 문제가 발생할 수 있습니다. 다음 스크립트를 실행하여 기존 에러 코드 사용 현황을 확인하세요: 🏁 Script executed: #!/bin/bash
# 기존 에러 코드 사용 현황 검색
echo "=== RECORD 관련 에러 코드 사용 현황 ==="
rg -n "120000|120001|120002" --type java
echo "=== USER_ROOM 관련 에러 코드 사용 현황 ==="
rg -n "130000" --type java
echo "=== CATEGORY 관련 에러 코드 사용 현황 ==="
rg -n "140000" --type javaLength of output: 1050 RECORD_CANNOT_WRITE_IN_EXPIRED_ROOM 에러 코드 범위 수정 필요
- RECORD_CANNOT_WRITE_IN_EXPIRED_ROOM(HttpStatus.BAD_REQUEST, 120003, "만료된 방에는 기록을 남길 수 없습니다."),
+ RECORD_CANNOT_WRITE_IN_EXPIRED_ROOM(HttpStatus.BAD_REQUEST, 130003, "만료된 방에는 기록을 남길 수 없습니다."),수정 후 다음 사항을 점검하세요:
🤖 Prompt for AI Agents |
||||||
|
|
||||||
| ; | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package konkuk.thip.common.util; | ||
|
|
||
| import org.springframework.stereotype.Component; | ||
|
|
||
| import java.time.Duration; | ||
| import java.time.LocalDateTime; | ||
|
|
||
| @Component | ||
| public class DateUtil { | ||
|
|
||
| //마지막 활동 시간 포맷팅 -> ex. 1분 전, 1시간 전, 1일 전 | ||
| public String formatLastActivityTime(LocalDateTime createdAt) { | ||
| long minutes = Duration.between(createdAt, LocalDateTime.now()).toMinutes(); | ||
| if (minutes < 1) return "방금 전"; | ||
| if (minutes < 60) return minutes + "분 전"; | ||
| long hours = minutes / 60; | ||
| if (hours < 24) return hours + "시간 전"; | ||
| return (hours / 24) + "일 전"; | ||
| } | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package konkuk.thip.post.adapter.out.persistence; | ||
|
|
||
| import konkuk.thip.post.application.port.out.PostLikeCommandPort; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Repository; | ||
|
|
||
| @Repository | ||
| @RequiredArgsConstructor | ||
| public class PostLikeCommandPersistenceAdapter implements PostLikeCommandPort { | ||
|
|
||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package konkuk.thip.post.adapter.out.persistence; | ||
|
|
||
| import konkuk.thip.post.adapter.out.jpa.PostLikeJpaEntity; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import org.springframework.stereotype.Repository; | ||
|
|
||
| @Repository | ||
| public interface PostLikeJpaRepository extends JpaRepository<PostLikeJpaEntity, Long> { | ||
| int countByPostJpaEntity_PostId(Long postId); | ||
|
|
||
| boolean existsByPostJpaEntity_PostIdAndUserJpaEntity_UserId(Long postId, Long userId); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package konkuk.thip.post.adapter.out.persistence; | ||
|
|
||
| import konkuk.thip.post.application.port.out.PostLikeQueryPort; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Repository; | ||
|
|
||
| @Repository | ||
| @RequiredArgsConstructor | ||
| public class PostLikeQueryPersistenceAdapter implements PostLikeQueryPort { | ||
|
|
||
| private final PostLikeJpaRepository postLikeJpaRepository; | ||
|
|
||
| @Override | ||
| public int countByPostId(Long postId) { | ||
| return postLikeJpaRepository.countByPostJpaEntity_PostId(postId); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean existsByPostIdAndUserId(Long postId, Long userId) { | ||
| return postLikeJpaRepository.existsByPostJpaEntity_PostIdAndUserJpaEntity_UserId(postId, userId); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package konkuk.thip.post.application.port.out; | ||
|
|
||
| public interface PostLikeCommandPort { | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package konkuk.thip.post.application.port.out; | ||
|
|
||
| public interface PostLikeQueryPort { | ||
|
|
||
| int countByPostId(Long postId); | ||
| boolean existsByPostIdAndUserId(Long postId, Long userId); | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,10 +1,43 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| package konkuk.thip.record.adapter.in.web; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.springframework.web.bind.annotation.PathVariable; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.springframework.web.bind.annotation.RequestParam; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.springframework.web.bind.annotation.RestController; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @RestController | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @RequiredArgsConstructor | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public class RecordQueryController { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private final RecordSearchUseCase recordSearchUseCase; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @GetMapping("/rooms/{roomId}/posts") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public BaseResponse<RecordSearchResponse> viewRecordList( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @PathVariable final Long roomId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @RequestParam final String type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @RequestParam final String sort, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @RequestParam(required = false) final Integer pageStart, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @RequestParam(required = false) final Integer pageEnd, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @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() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+20
to
+41
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. 🛠️ Refactor suggestion 입력 검증 및 문서화 추가 필요 컨트롤러 메서드에 입력 검증과 문서화가 필요합니다: +import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
+import jakarta.validation.constraints.Positive;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+
+ /**
+ * 방의 기록 및 투표 목록을 조회합니다.
+ *
+ * @param roomId 방 ID
+ * @param type 검색 타입 (all, record, vote, mine)
+ * @param sort 정렬 기준 (latest, oldest, popular)
+ * @param pageStart 페이지 시작 번호 (선택사항)
+ * @param pageEnd 페이지 끝 번호 (선택사항)
+ * @param pageNum 페이지 번호
+ * @param userId 현재 사용자 ID
+ * @return 검색 결과
+ */
+ @Operation(summary = "방의 기록 및 투표 목록 조회")
@GetMapping("/rooms/{roomId}/posts")
public BaseResponse<RecordSearchResponse> viewRecordList(
+ @Parameter(description = "방 ID", required = true)
+ @NotNull
@PathVariable final Long roomId,
+ @Parameter(description = "검색 타입", required = true)
+ @NotBlank
@RequestParam final String type,
+ @Parameter(description = "정렬 기준", required = true)
+ @NotBlank
@RequestParam final String sort,
+ @Parameter(description = "페이지 시작 번호")
+ @Positive
@RequestParam(required = false) final Integer pageStart,
+ @Parameter(description = "페이지 끝 번호")
+ @Positive
@RequestParam(required = false) final Integer pageEnd,
+ @Parameter(description = "페이지 번호", required = true)
+ @Positive
@RequestParam final Integer pageNum,
+ @Parameter(description = "사용자 ID", hidden = true)
@UserId final Long userId
) {📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| package konkuk.thip.record.adapter.in.web.response; | ||
|
|
||
| import konkuk.thip.record.domain.Record; | ||
| import konkuk.thip.user.domain.User; | ||
| import lombok.Builder; | ||
|
|
||
| @Builder | ||
| public record RecordDto( | ||
| String postDate, | ||
| int page, | ||
| Long userId, | ||
| String nickName, | ||
| String profileImageUrl, | ||
| String content, | ||
| int likeCount, | ||
| int commentCount, | ||
| boolean isLiked, | ||
| boolean isWriter, | ||
| Long recordId | ||
| ) implements RecordSearchResponse.PostDto { | ||
| @Override | ||
| public String type() { | ||
| return "RECORD"; | ||
| } | ||
|
|
||
| public static RecordDto of(Record record, String postDate, User user, int likeCount, int commentCount, boolean isLiked, boolean isWriter) { | ||
| return RecordDto.builder() | ||
| .postDate(postDate) | ||
| .page(record.getPage()) | ||
| .userId(record.getCreatorId()) | ||
| .nickName(user.getNickname()) | ||
| .profileImageUrl(user.getImageUrl()) | ||
| .content(record.getContent()) | ||
| .likeCount(likeCount) | ||
| .commentCount(commentCount) | ||
| .isLiked(isLiked) | ||
| .isWriter(isWriter) | ||
| .recordId(record.getId()) | ||
| .build(); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| package konkuk.thip.record.adapter.in.web.response; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonSubTypes; | ||
| import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public record RecordSearchResponse( | ||
| List<PostDto> recordList, | ||
| Integer page, | ||
| Integer size, | ||
| Boolean first, | ||
| Boolean last | ||
| ){ | ||
|
|
||
| public static RecordSearchResponse of(List<PostDto> recordList, | ||
| Integer page, | ||
| Integer size, | ||
| Boolean first, | ||
| Boolean last) { | ||
| return new RecordSearchResponse(recordList, page, size, first, last); | ||
| } | ||
|
|
||
| @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") | ||
| @JsonSubTypes({ | ||
| @JsonSubTypes.Type(value = RecordDto.class, name = "RECORD"), | ||
| @JsonSubTypes.Type(value = VoteDto.class, name = "VOTE") | ||
| }) | ||
| public sealed interface PostDto permits RecordDto, VoteDto { | ||
| String type(); | ||
| String postDate(); | ||
| int page(); | ||
| Long userId(); | ||
| String nickName(); | ||
| String profileImageUrl(); | ||
| String content(); | ||
| int likeCount(); | ||
| int commentCount(); | ||
| boolean isLiked(); | ||
| boolean isWriter(); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| package konkuk.thip.record.adapter.in.web.response; | ||
|
|
||
| import konkuk.thip.user.domain.User; | ||
| import konkuk.thip.vote.domain.Vote; | ||
| import konkuk.thip.vote.domain.VoteItem; | ||
| import lombok.Builder; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Builder | ||
| public record VoteDto( | ||
| String postDate, | ||
| int page, | ||
| Long userId, | ||
| String nickName, | ||
| String profileImageUrl, | ||
| String content, | ||
| int likeCount, | ||
| int commentCount, | ||
| boolean isLiked, | ||
| boolean isWriter, | ||
| Long voteId, | ||
| List<VoteItemDto> voteItems | ||
| ) implements RecordSearchResponse.PostDto { | ||
| @Override | ||
| public String type() { | ||
| return "VOTE"; | ||
| } | ||
|
|
||
| public static VoteDto of( | ||
| Vote vote, String postDate, User user, int likeCount, int commentCount, boolean isLiked, boolean isWriter, | ||
| List<VoteItemDto> voteItems | ||
| ) { | ||
| return VoteDto.builder() | ||
| .postDate(postDate) | ||
| .page(vote.getPage()) | ||
| .userId(vote.getCreatorId()) | ||
| .nickName(user.getNickname()) | ||
| .profileImageUrl(user.getImageUrl()) | ||
| .content(vote.getContent()) | ||
| .likeCount(likeCount) | ||
| .commentCount(commentCount) | ||
| .isLiked(isLiked) | ||
| .isWriter(isWriter) | ||
| .voteId(vote.getId()) | ||
| .voteItems(voteItems) | ||
| .build(); | ||
| } | ||
|
|
||
| public record VoteItemDto( | ||
| Long voteItemId, | ||
| String itemName, | ||
| int percentage, | ||
| boolean isVoted | ||
| ) { | ||
| public static VoteItemDto of(VoteItem voteItem, int percentage, boolean isVoted) { | ||
| return new VoteItemDto( | ||
| voteItem.getId(), | ||
| voteItem.getItemName(), | ||
| percentage, | ||
| isVoted | ||
| ); | ||
| } | ||
| } | ||
| } |
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.
에러 코드 번호 불일치 수정 필요
에러 코드가 120003으로 되어 있으나, 130000 범위에 속해야 합니다.
📝 Committable suggestion
🤖 Prompt for AI Agents