Skip to content

Commit

Permalink
๐Ÿ”จ Refactor/#165 - 6.2 ๊ฒŒ์‹œ๊ธ€ ์ƒ์„ธ๋ณด๊ธฐ์—, ๋‚ด๊ฐ€ ์“ด ๊ธ€์ธ์ง€ ์—ฌ๋ถ€ ์˜๋ฏธํ•˜๋Š” is_me ํ•„๋“œ ์ถ”๊ฐ€ (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
dongkyeomjang authored Nov 26, 2024
1 parent 133830c commit d0756a1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,19 @@ public static class WriterInfoDto extends SelfValidating<WriterInfoDto> {
@JsonProperty("masked_nickname")
private final String maskedNickname;

@JsonProperty("is_me")
private final Boolean isMe;

@Builder
public WriterInfoDto(String profileImgUrl, String maskedNickname) {
public WriterInfoDto(String profileImgUrl, String maskedNickname, Boolean isMe) {
this.profileImgUrl = profileImgUrl;
this.maskedNickname = maskedNickname;
this.isMe = isMe;

this.validateSelf();
}

public static WriterInfoDto fromEntity(User user) {
public static WriterInfoDto of(User user, Boolean isMe) {

String nickname = user.getNickName();
String maskedNickname;
Expand All @@ -64,6 +68,7 @@ public static WriterInfoDto fromEntity(User user) {
return WriterInfoDto.builder()
.maskedNickname(maskedNickname)
.profileImgUrl(user.getProfileImgUrl())
.isMe(isMe)
.build();
}
}
Expand Down Expand Up @@ -138,9 +143,9 @@ public static BoardInfoDto of(
}
}

public static ReadBoardDetailResponseDto of(Board board, User user, Integer likeCount, Integer commentCount, Boolean isLiked) {
public static ReadBoardDetailResponseDto of(Board board, User user, Boolean isMe, Integer likeCount, Integer commentCount, Boolean isLiked) {
return ReadBoardDetailResponseDto.builder()
.writerInfo(WriterInfoDto.fromEntity(user))
.writerInfo(WriterInfoDto.of(user, isMe))
.boardInfo(BoardInfoDto.of(board, likeCount, commentCount, isLiked))
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,13 @@ public ReadBoardDetailResponseDto execute(UUID accountId, Long boardId) {
// ์ž‘์„ฑ์ž ์กฐํšŒ
User writer = board.getUser();

// ์ž‘์„ฑ์ž๊ฐ€ ๋ณธ์ธ์ธ์ง€ ์—ฌ๋ถ€ ์กฐํšŒ
Boolean isMe = writer.getId().equals(user.getId());

return ReadBoardDetailResponseDto.of(
board,
writer,
isMe,
likeCount,
commentCount,
isLiked
Expand Down

0 comments on commit d0756a1

Please sign in to comment.