Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ public VerificationDetailResponseDto toDetailDto(
boolean canEdit,
boolean canDelete,
boolean canSelectComment,
boolean isLiked,
boolean isScrapped,
boolean canWriteComment,
Long adoptedCommentId
) {
Expand Down Expand Up @@ -184,6 +186,8 @@ public VerificationDetailResponseDto toDetailDto(
.canEdit(canEdit)
.canDelete(canDelete)
.canSelectComment(canSelectComment)
.isLiked(isLiked)
.isScrapped(isScrapped)
.canWriteComment(canWriteComment)
.adoptedCommentId(adoptedCommentId)
.showResolvedBadge(verification.getIsResolved())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.hrr.backend.domain.user.entity.enums.UserLevel;
import com.hrr.backend.domain.verification.entity.enums.VerificationPostType;
import com.hrr.backend.domain.verification.entity.enums.VerificationStatus;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
Expand Down Expand Up @@ -47,6 +48,12 @@ public class VerificationDetailResponseDto {
private Boolean canDelete;
private Boolean canSelectComment;

@Schema(description = "현재 로그인 사용자의 좋아요 여부", example = "true")
private Boolean isLiked;

@Schema(description = "현재 로그인 사용자의 스크랩 여부", example = "false")
private Boolean isScrapped;

//프론트가 받기 쉽게
private boolean canWriteComment;
private Long adoptedCommentId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ INSERT IGNORE INTO verification_like (user_id, verification_id, created_at, upda
void insertIgnore(@Param("userId") Long userId, @Param("verificationId") Long verificationId);

void deleteByUserIdAndVerificationId(Long userId, Long verificationId);

boolean existsByUserIdAndVerificationId(Long userId, Long verificationId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ INSERT IGNORE INTO verification_scrap (user_id, verification_id, created_at, upd

void deleteByUserIdAndVerificationId(Long userId, Long verificationId);

boolean existsByUserIdAndVerificationId(Long userId, Long verificationId);

@Query("""
SELECT v FROM VerificationScrap vs
JOIN vs.verification v
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,9 @@ public VerificationDetailResponseDto getVerificationDetail(
&& Boolean.TRUE.equals(verification.getIsQuestion())
&& !isResolved;

boolean isLiked = verificationLikeRepository.existsByUserIdAndVerificationId(currentUserId, verificationId);
boolean isScrapped = verificationScrapRepository.existsByUserIdAndVerificationId(currentUserId, verificationId);
Comment thread
yangjiae12 marked this conversation as resolved.
Resolved

boolean canWriteComment = false;
if (currentUserId != null) {
Long challengeId = verification.getRoundRecord().getRound().getChallenge().getId();
Expand Down Expand Up @@ -444,6 +447,8 @@ public VerificationDetailResponseDto getVerificationDetail(
canEdit,
canDelete,
canSelectComment,
isLiked,
isScrapped,
canWriteComment,
adoptedCommentId
);
Expand Down Expand Up @@ -541,6 +546,9 @@ public VerificationDetailResponseDto updateVerification(Long verificationId, Lon
.findFirst()
.orElse(null);

boolean isLiked = verificationLikeRepository.existsByUserIdAndVerificationId(currentUserId, verificationId);
boolean isScrapped = verificationScrapRepository.existsByUserIdAndVerificationId(currentUserId, verificationId);

boolean canWriteComment = false;
if (currentUserId != null) {
Long challengeId = verification.getRoundRecord().getRound().getChallenge().getId();
Expand All @@ -559,6 +567,8 @@ public VerificationDetailResponseDto updateVerification(Long verificationId, Lon
canEdit,
canDelete,
canSelectComment,
isLiked,
isScrapped,
canWriteComment,
adoptedCommentId
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,14 @@ void getVerificationDetail_Success_CanWriteComment() {
given(verificationConverter.toDetailDto(
any(Verification.class), // 1. Verification
any(CommentListResponseDto.class), // 2. CommentListResponseDto
anyBoolean(), // 3. isLiked
anyBoolean(), // 3. isMine
anyBoolean(), // 4. canEdit
anyBoolean(), // 5. canDelete
anyBoolean(), // 6. canReport
anyBoolean(), // 7. canWriteComment (핵심 검증 대상)
any() // 8. currentUser (User 객체 혹은 null)
anyBoolean(), // 6. canSelectComment
anyBoolean(), // 7. isLiked
anyBoolean(), // 8. isScrapped
anyBoolean(), // 9. canWriteComment
any() // 10. adoptedCommentId
Comment thread
yangjiae12 marked this conversation as resolved.
Resolved
)).willReturn(expectedDto);

// when
Expand Down Expand Up @@ -230,6 +232,7 @@ void getVerificationDetail_Success_CannotWriteComment() {
// Converter Mock 부분도 인자 개수 8개로 맞춤
given(verificationConverter.toDetailDto(
any(), any(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(),
anyBoolean(), anyBoolean(),
eq(false), // canWriteComment = false 예상
any()
)).willReturn(expectedDto);
Expand Down