Skip to content

Commit

Permalink
refactor: isBlockedComment를 Lombok getter에서 생략 후 직접 getter 구현 (#400)
Browse files Browse the repository at this point in the history
* refactor(CommentDto): Lombok getter에서 isBlockedComment를 생략 후 직접 getter 구현

* refactor(ReplyDto): Lombok getter에서 isBlockedComment를 생략 후 직접 getter 구현
  • Loading branch information
hoonyworld authored Sep 22, 2024
1 parent e85d400 commit 2219c36
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@

import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;

import org.sopt.makers.crew.main.entity.comment.Comment;
import org.sopt.makers.crew.main.entity.user.User;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.querydsl.core.annotations.QueryProjection;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.AccessLevel;
import lombok.Getter;

@Getter
Expand Down Expand Up @@ -55,12 +53,13 @@ public class CommentDto {
private final List<ReplyDto> replies;

@Schema(description = "차단여부", example = "false")
@Getter(AccessLevel.NONE)
@NotNull
private final Boolean isBlockedComment;
private final boolean isBlockedComment;

@QueryProjection
public CommentDto(Integer id, String contents, CommentWriterDto user, LocalDateTime createdDate, int likeCount,
boolean isLiked, boolean isWriter, int order, List<ReplyDto> replies, Boolean isBlockedComment) {
boolean isLiked, boolean isWriter, int order, List<ReplyDto> replies, boolean isBlockedComment) {
this.id = id;
this.contents = contents;
this.user = user;
Expand All @@ -74,7 +73,7 @@ public CommentDto(Integer id, String contents, CommentWriterDto user, LocalDateT
}

public static CommentDto of(Comment comment, boolean isLiked, boolean isWriter, List<ReplyDto> replies,
Boolean isBlockedComment) {
boolean isBlockedComment) {
Integer userId = comment.getUser() == null ? null : comment.getUser().getId();
Integer orgId = comment.getUser() == null ? null : comment.getUser().getOrgId();
String userName = comment.getUser() == null ? null : comment.getUser().getName();
Expand All @@ -85,4 +84,8 @@ public static CommentDto of(Comment comment, boolean isLiked, boolean isWriter,
profileImage), comment.getCreatedDate(), comment.getLikeCount(),
isLiked, isWriter, comment.getOrder(), replies, isBlockedComment);
}

public boolean getIsBlockedComment() {
return isBlockedComment;
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package org.sopt.makers.crew.main.comment.v2.dto.response;

import java.time.LocalDateTime;

import org.sopt.makers.crew.main.entity.comment.Comment;

import com.querydsl.core.annotations.QueryProjection;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.AccessLevel;
import lombok.Getter;

@Getter
Expand Down Expand Up @@ -44,12 +48,13 @@ public class ReplyDto {
private final int order;

@Schema(description = "차단여부", example = "false")
@Getter(AccessLevel.NONE)
@NotNull
private final Boolean isBlockedComment;
private final boolean isBlockedComment;

@QueryProjection
public ReplyDto(Integer id, String contents, CommentWriterDto user, LocalDateTime createdDate, int likeCount,
Boolean isLiked, Boolean isWriter, int order, Boolean isBlockedComment) {
Boolean isLiked, Boolean isWriter, int order, boolean isBlockedComment) {
this.id = id;
this.contents = contents;
this.user = user;
Expand All @@ -61,10 +66,14 @@ public ReplyDto(Integer id, String contents, CommentWriterDto user, LocalDateTim
this.isBlockedComment = isBlockedComment;
}

public static ReplyDto of(Comment comment, boolean isLiked, boolean isWriter, boolean isBlockedComment) {
public static ReplyDto of(Comment comment, boolean isLiked, boolean isWriter, boolean isBlockedComment) {
return new ReplyDto(comment.getId(), comment.getContents(),
new CommentWriterDto(comment.getUser().getId(), comment.getUser().getOrgId(), comment.getUser().getName(),
comment.getUser().getProfileImage()), comment.getCreatedDate(), comment.getLikeCount(),
isLiked, isWriter, comment.getOrder(), isBlockedComment);
}

public boolean getIsBlockedComment() {
return isBlockedComment;
}
}

0 comments on commit 2219c36

Please sign in to comment.