-
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
Open
seonghooni
wants to merge
7
commits into
main
Choose a base branch
from
feature/reply-json
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+237
−11
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
efe6c3f
build(comment/reply): jackson-databind, jackson-datatype
seonghooni 40536fb
refactor(comment/reply): add @SuperBuilder to BaseEntity
seonghooni 233ff63
refactor(comment/reply): add json column to create_tb_comment.sql
seonghooni 98b3f07
feat(comment/reply): add replies json column to commentEntity
seonghooni 52d5d13
feat(comment/reply): refactor EntityMapper
seonghooni 29d1d57
feat(comment/reply): modify for service using json column
seonghooni d707103
feat(comment/reply): add ReplyListConverter for json column
seonghooni 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
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
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
6 changes: 6 additions & 0 deletions
6
...plication/src/main/java/nettee/comment/application/port/CommentCommandRepositoryPort.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,13 +1,19 @@ | ||
package nettee.comment.application.port; | ||
|
||
import java.util.List; | ||
import nettee.comment.domain.Comment; | ||
import nettee.comment.domain.type.CommentStatus; | ||
import nettee.reply.domain.Reply; | ||
|
||
public interface CommentCommandRepositoryPort { | ||
|
||
Comment save(Comment comment); | ||
|
||
Comment update(Comment comment); | ||
|
||
Comment findById(Long id); | ||
|
||
void updateStatus(Long id, CommentStatus status); | ||
|
||
void updateReplies(Long id, List<Reply> replyList); | ||
} |
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
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
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
41 changes: 41 additions & 0 deletions
41
...nt/driven/rdb/src/main/java/nettee/comment/driven/rdb/entity/type/ReplyListConverter.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,41 @@ | ||
package nettee.comment.driven.rdb.entity.type; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.SerializationFeature; | ||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; | ||
import jakarta.persistence.AttributeConverter; | ||
import jakarta.persistence.Converter; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import nettee.reply.driven.rdb.entity.ReplyEntity; | ||
|
||
import static nettee.comment.exception.CommentCommandErrorCode.DEFAULT; | ||
|
||
@Converter | ||
public class ReplyListConverter implements AttributeConverter<List<ReplyEntity>, String> { | ||
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. 아하 ReplyEntity의 LongBaseTimeEntity 시간 관련 필드들을 직렬화, 역직렬화하기 위해서는 해당 작업이 필요하나 보네요! |
||
|
||
@Override | ||
public String convertToDatabaseColumn(List<ReplyEntity> replies) { | ||
try { | ||
return objectMapper.writeValueAsString(replies); | ||
} catch (JsonProcessingException e) { | ||
throw DEFAULT.exception(); | ||
} | ||
} | ||
|
||
@Override | ||
public List<ReplyEntity> convertToEntityAttribute(String dbData) { | ||
try { | ||
if (dbData == null || dbData.isBlank()) return new ArrayList<>(); | ||
return objectMapper.readValue(dbData, new TypeReference<List<ReplyEntity>>() {}); | ||
} catch (JsonProcessingException e) { | ||
throw DEFAULT.exception(); | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -4,9 +4,10 @@ | |
import nettee.comment.domain.Comment; | ||
import nettee.comment.driven.rdb.entity.CommentEntity; | ||
import nettee.comment.model.CommentQueryModels.CommentDetail; | ||
import nettee.reply.driven.rdb.persistence.mapper.ReplyEntityMapper; | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. 현재 mapper 클래스에서 다른 mapper를 사용할 수 있게 지정할 수도 있네요..!! |
||
public interface CommentEntityMapper { | ||
|
||
Comment toDomain(CommentEntity commentEntity); | ||
|
Oops, something went wrong.
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.
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 컬럼 지정을 이렇게 하네요!