-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
๐จ Refactor/#177 - RabbitMQ์ RPC ์์ฒญ-์๋ต ํจํด์ ์ฌ์ฉํ์ฌ ๋๊ธ ๋ฐ ์ข์์ ์์ฑ ์, Responsโฆ
โฆeBody ๋ฐํํ๊ฒ ๋ณ๊ฒฝ (#178) * ๐จ Refactor/#177 - RabbitMQ์ RPC ์์ฒญ-์๋ต ํจํด์ ์ฌ์ฉํ์ฌ, ๋๊ธ ์์ฑ ์ * ๐จ Refactor/#177 - RabbitMQ์ RPC ์์ฒญ-์๋ต ํจํด์ ์ฌ์ฉํ์ฌ ์ข์์ ์์ฑ ์, ResponseBody ๋ฐํํ๊ฒ ๋ณ๊ฒฝ
- Loading branch information
1 parent
bb5fe1b
commit 97890ff
Showing
16 changed files
with
185 additions
and
27 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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
108 changes: 108 additions & 0 deletions
108
...in/java/com/daon/onjung/suggestion/application/dto/response/CreateCommentResponseDto.java
This file contains 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,108 @@ | ||
package com.daon.onjung.suggestion.application.dto.response; | ||
|
||
import com.daon.onjung.account.domain.User; | ||
import com.daon.onjung.core.dto.SelfValidating; | ||
import com.daon.onjung.core.utility.DateTimeUtil; | ||
import com.daon.onjung.suggestion.domain.Comment; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class CreateCommentResponseDto extends SelfValidating<CreateCommentResponseDto> { | ||
|
||
@JsonProperty("writer_info") | ||
private final WriterInfoDto writerInfo; | ||
|
||
@JsonProperty("comment_info") | ||
private final CommentInfoDto commentInfo; | ||
|
||
@Builder | ||
public CreateCommentResponseDto(WriterInfoDto writerInfo, CommentInfoDto commentInfo) { | ||
this.writerInfo = writerInfo; | ||
this.commentInfo = commentInfo; | ||
|
||
this.validateSelf(); | ||
} | ||
|
||
@Getter | ||
public static class WriterInfoDto extends SelfValidating<WriterInfoDto> { | ||
|
||
@JsonProperty("profile_img_url") | ||
private final String profileImgUrl; | ||
|
||
@JsonProperty("masked_nickname") | ||
private final String maskedNickname; | ||
|
||
@JsonProperty("is_me") | ||
private final Boolean isMe; | ||
|
||
@Builder | ||
public WriterInfoDto(String profileImgUrl, String maskedNickname, Boolean isMe) { | ||
this.profileImgUrl = profileImgUrl; | ||
this.maskedNickname = maskedNickname; | ||
this.isMe = isMe; | ||
|
||
this.validateSelf(); | ||
} | ||
|
||
public static WriterInfoDto of(User user, Boolean isMe) { | ||
String nickname = user.getNickName(); | ||
String maskedNickname; | ||
|
||
if (nickname.length() == 1) { | ||
maskedNickname = nickname; | ||
} else if (nickname.length() == 2) { | ||
maskedNickname = nickname.charAt(0) + "*"; | ||
} else { | ||
String firstChar = nickname.substring(0, 1); | ||
String lastChar = nickname.substring(nickname.length() - 1); | ||
String middleMask = "*".repeat(nickname.length() - 2); | ||
maskedNickname = firstChar + middleMask + lastChar; | ||
} | ||
|
||
return WriterInfoDto.builder() | ||
.maskedNickname(maskedNickname) | ||
.profileImgUrl(user.getProfileImgUrl()) | ||
.isMe(isMe) | ||
.build(); | ||
} | ||
} | ||
|
||
@Getter | ||
public static class CommentInfoDto extends SelfValidating<CommentInfoDto> { | ||
|
||
@JsonProperty("id") | ||
private final Long id; | ||
|
||
@JsonProperty("content") | ||
private final String content; | ||
|
||
@JsonProperty("posted_at") | ||
private final String postedAt; | ||
|
||
@Builder | ||
public CommentInfoDto(Long id, String content, String postedAt) { | ||
this.id = id; | ||
this.content = content; | ||
this.postedAt = postedAt; | ||
|
||
this.validateSelf(); | ||
} | ||
|
||
public static CommentInfoDto fromEntity(Comment comment) { | ||
return CommentInfoDto.builder() | ||
.id(comment.getId()) | ||
.content(comment.getContent()) | ||
.postedAt(DateTimeUtil.calculatePostedAgo(comment.getCreatedAt())) | ||
.build(); | ||
} | ||
} | ||
|
||
public static CreateCommentResponseDto of(User user, Boolean isMe, Comment comment) { | ||
return CreateCommentResponseDto.builder() | ||
.writerInfo(WriterInfoDto.of(user, isMe)) | ||
.commentInfo(CommentInfoDto.fromEntity(comment)) | ||
.build(); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...va/com/daon/onjung/suggestion/application/dto/response/CreateOrDeleteLikeResponseDto.java
This file contains 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,26 @@ | ||
package com.daon.onjung.suggestion.application.dto.response; | ||
|
||
import com.daon.onjung.core.dto.SelfValidating; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class CreateOrDeleteLikeResponseDto extends SelfValidating<CreateOrDeleteLikeResponseDto> { | ||
|
||
@JsonProperty("is_like") | ||
private final Boolean isLike; | ||
|
||
@Builder | ||
public CreateOrDeleteLikeResponseDto(Boolean isLike) { | ||
this.isLike = isLike; | ||
|
||
this.validateSelf(); | ||
} | ||
|
||
public static CreateOrDeleteLikeResponseDto of(Boolean isLike) { | ||
return CreateOrDeleteLikeResponseDto.builder() | ||
.isLike(isLike) | ||
.build(); | ||
} | ||
} |
This file contains 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 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 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 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
Oops, something went wrong.