Skip to content

Commit

Permalink
Merge pull request #156 from Seoul-NolGoat/dev
Browse files Browse the repository at this point in the history
[Release] 2차 배포
  • Loading branch information
yonghyeonpark authored Jan 31, 2025
2 parents 45155f3 + 51a848b commit 7b0e55f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/main/java/wad/seoul_nolgoat/domain/comment/Comment.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,20 @@ public class Comment extends BaseTimeEntity {
private Party party;

private String content;
private boolean isDeleted;

public Comment(User writer, Party party, String content) {
this.writer = writer;
this.party = party;
this.content = content;
this.isDeleted = false;
}

public void update(String content) {
this.content = content;
}

public void delete() {
this.isDeleted = true;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package wad.seoul_nolgoat.domain.comment;

import com.querydsl.core.types.Projections;
import com.querydsl.core.types.dsl.Expressions;
import com.querydsl.jpa.impl.JPAQuery;
import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.RequiredArgsConstructor;
Expand All @@ -17,6 +18,8 @@
@RequiredArgsConstructor
public class CommentRepositoryCustomImpl implements CommentRepositoryCustom {

private static final String DELETED_COMMENT_MESSAGE = "삭제된 댓글입니다";

private final JPAQueryFactory jpaQueryFactory;

@Override
Expand All @@ -26,8 +29,12 @@ public Page<CommentDetailsForUserDto> findCommentsByLoginId(String loginId, Page
Projections.constructor(
CommentDetailsForUserDto.class,
comment.id,
comment.content,
Expressions.cases()
.when(comment.isDeleted.isTrue())
.then(DELETED_COMMENT_MESSAGE)
.otherwise(comment.content),
comment.createdDate,
comment.isDeleted,
comment.party.id
)
)
Expand Down Expand Up @@ -57,8 +64,12 @@ public List<CommentDetailsForPartyDto> findCommentsByPartyId(Long partyId) {
Projections.constructor(
CommentDetailsForPartyDto.class,
comment.id,
comment.content,
Expressions.cases()
.when(comment.isDeleted.isTrue())
.then(DELETED_COMMENT_MESSAGE)
.otherwise(comment.content),
comment.createdDate,
comment.isDeleted,
comment.writer.id,
comment.writer.nickname,
comment.writer.profileImage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void delete(String loginId, Long commentId) {
throw new ApplicationException(COMMENT_DELETE_NOT_AUTHORIZED);
}

commentRepository.delete(comment);
comment.delete();
}

public Page<CommentDetailsForUserDto> findCommentsByLoginId(String loginId, Pageable pageable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class CommentDetailsForPartyDto {
private final Long commentId;
private final String content;
private final LocalDateTime createdDate;
private final Boolean isDeleted;
private final Long writerId;
private final String writerNickname;
private final String writerProfileImage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ public class CommentDetailsForUserDto {
private final Long commentId;
private final String content;
private final LocalDateTime createdDate;
private final Boolean isDeleted;
private final Long partyId;
}

0 comments on commit 7b0e55f

Please sign in to comment.