-
Notifications
You must be signed in to change notification settings - Fork 0
☀️ Comment: 댓글별 첫 페이지 답글을 JSON 필드로 관리 #110
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
base: main
Are you sure you want to change the base?
Conversation
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.
꼼꼼히 주석을 달아주셔, 코드를 읽고 이해하기 수월했습니다!
Jpa 내 Pageable 사용과 JSON 컬럼 지정, Mapper 사용 측면에서 새롭게 알아가는 부분도 많았던 리뷰였던 것 같습니다!
수고 많으셨습니다!!👍
@@ -24,11 +33,16 @@ public class CommentEntity extends LongBaseTimeEntity { | |||
@Convert(converter = CommentEntityStatusConverter.class) | |||
public CommentEntityStatus status; | |||
|
|||
@Convert(converter = ReplyListConverter.class) | |||
@JdbcTypeCode(SqlTypes.JSON) |
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.
Entity에서의 json 컬럼 지정을 이렇게 하네요!
|
||
private final ObjectMapper objectMapper = new ObjectMapper() | ||
.registerModule(new JavaTimeModule()) | ||
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); // 날짜 필드를 숫자가 아닌 ISO 8601 문자열("2025-06-06T04:37:00Z")로 직렬화합니다. |
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.
아하 ReplyEntity의 LongBaseTimeEntity 시간 관련 필드들을 직렬화, 역직렬화하기 위해서는 해당 작업이 필요하나 보네요!
import org.mapstruct.Mapper; | ||
|
||
@Mapper(componentModel = "spring") | ||
@Mapper(componentModel = "spring", uses = ReplyEntityMapper.class) |
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.
현재 mapper 클래스에서 다른 mapper를 사용할 수 있게 지정할 수도 있네요..!!
@Param("commentId") Long commentId, | ||
@Param("createdAt") Instant createdAt, | ||
@Param("status") ReplyEntityStatus status, | ||
Pageable 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.
모든 데이터를 조회해서 메모리에 불러오는 대신에, 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.
댓글의 답글을 JSON 컬럼으로 관리하는 방식이 깔끔하게 잘 설계된 것 같습니다~!
페이지 내 reply만 comment 테이블에 반영하는 구조도 성능을 잘 고려하신 부분이라 인상 깊습니다.
ReplyListConverter 예외 처리도 꼼꼼하게 되어 있어서 좋았습니다.
리뷰를 보기 편하게 잘 적어주셔서 감사합니다 ^^
성능 비교 결과도 기대됩니다, 좋은 작업 감사합니다!
Issues
Description
✅ JSON 컬럼 직렬화를 위해 필요한 라이브러리 import
✅ CommentEntity 클래스
✅ ReplyListConverter 클래스
Review Points
향후 성능 테스트를 위해 남겨 놓았습니다. 코드 리뷰시 참고해주시면 감사하겠습니다!
How Has This Been Tested?
Additional Notes