Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
aa166aa
feat: 응답 dto 수정
Hminkyung Aug 11, 2026
380a708
feat: 현재 라운드 인증 횟수로 변경 후 현재 라운드 부실 인증 횟수 수정
Hminkyung Aug 11, 2026
471f230
feat: 라운드 부실인증 계산 후 경고와 함께 산출
Hminkyung Aug 11, 2026
eb39fa3
feat: roundrecord 에 인증글 삭제 시 인증 횟수를 감소하는 메소드 추가
Hminkyung Aug 11, 2026
cffd93c
feat: 부실 인증 신고 수만 조회하게 변경
Hminkyung Aug 11, 2026
d1beb27
feat: 특정 인증글에 달린 부실인증 신고 전체 삭제 추가
Hminkyung Aug 11, 2026
f854850
feat: 라운드 기록의 인증 횟수와 경고 횟수를 재계산하는 쿼리문 추가
Hminkyung Aug 11, 2026
2df5e25
feat: 코드리뷰 추가
Hminkyung Aug 11, 2026
1527912
Merge branch 'develop' of https://github.com/Hrr-HabbitRoutineResult/…
Hminkyung Aug 19, 2026
1a6fc33
feat: migration 번호 변경
Hminkyung Aug 19, 2026
4194511
feat: 인증글에 삭제 컬럼 추가
Hminkyung Aug 19, 2026
fe032d3
feat: soft delete 메소드 추가 및 삭제 컬럼 추가
Hminkyung Aug 19, 2026
d8c994f
feat: 인증 상태에 삭제 추가
Hminkyung Aug 19, 2026
b303855
feat: 삭제했던 필드 추가
Hminkyung Aug 19, 2026
cc28458
feat: 삭제했던 필드 추가
Hminkyung Aug 19, 2026
d511873
feat: 중복 인증 방지 전용
Hminkyung Aug 19, 2026
d2d8c52
feat: 삭제된 인증글 처리
Hminkyung Aug 19, 2026
3bcf4dd
feat: 삭제된 인증글은 존재하지 않는 것으로 처리
Hminkyung Aug 19, 2026
ec543d6
feat: 인증글 삭제시 댓글 조회 불가
Hminkyung Aug 19, 2026
4f32a6b
feat: soft delete 된 인증글에는 포인트를 지급하지 않게 수정
Hminkyung Aug 19, 2026
93dbce4
feat: migration 파일 수정
Hminkyung Aug 19, 2026
be2a0a5
feat: 불필요한 코드 삭제
Hminkyung Aug 19, 2026
5007d71
feat: serviceTest 코드 수정
Hminkyung Aug 19, 2026
1cf8511
feat: roundrecord Test 기획 변경됨에 따라 테스트 코드 전면 교체
Hminkyung Aug 19, 2026
3be372f
feat: 인증글 삭제시 포인트 테스트 코드 추가
Hminkyung Aug 19, 2026
45f35d7
feat: 코드리뷰 반영
Hminkyung Aug 19, 2026
f7932e7
feat: 코드리뷰 누락된거 반영
Hminkyung Aug 19, 2026
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 @@ -52,6 +52,12 @@ public CommentResponseDto createComment(Long verificationId, Long userId, Commen
Verification verification = verificationRepository.findById(verificationId)
.orElseThrow(() -> new GlobalException(ErrorCode.VERIFICATION_NOT_FOUND));

// 삭제된 인증글에는 댓글을 달 수 없음
// soft delete로 행이 남아있으므로 명시적으로 걸러야 함
if (verification.isDeleted()) {
throw new GlobalException(ErrorCode.VERIFICATION_NOT_FOUND);
}

User user = userRepository.findById(userId)
.orElseThrow(() -> new GlobalException(ErrorCode.USER_NOT_FOUND));

Expand Down Expand Up @@ -143,6 +149,11 @@ public CommentListResponseDto getComments(Long verificationId, Long userId, Page
Verification verification = verificationRepository.findById(verificationId)
.orElseThrow(() -> new GlobalException(ErrorCode.VERIFICATION_NOT_FOUND));

// 삭제된 인증글의 댓글은 조회할 수 없음
if (verification.isDeleted()) {
throw new GlobalException(ErrorCode.VERIFICATION_NOT_FOUND);
}

// 조회하는 사용자 정보 가져오기
User currentUser = userRepository.findById(userId)
.orElseThrow(() -> new GlobalException(ErrorCode.USER_NOT_FOUND));
Expand Down Expand Up @@ -239,6 +250,11 @@ public CommentResponseDto updateComment(Long commentId, Long userId, CommentUpda
throw new GlobalException(ErrorCode.COMMENT_NOT_FOUND);
}

// 삭제된 인증글의 댓글은 수정할 수 없음
if (comment.getVerification().isDeleted()) {
throw new GlobalException(ErrorCode.VERIFICATION_NOT_FOUND);
}

if (!comment.getUser().getId().equals(userId)) {

throw new GlobalException(ErrorCode.COMMENT_UNAUTHORIZED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,13 @@ public void awardVerificationTriggeredPoints(Long verificationId) {
return;
}

// soft delete된 인증글에는 포인트를 지급하지 않는다.
if (verification.isDeleted()) {
log.info("[awardVerificationTriggeredPoints] 지급 대상 인증글이 삭제되어 포인트 지급을 건너뜁니다. verificationId={}",
verificationId);
return;
}

RoundRecord roundRecord = verification.getRoundRecord();
UserChallenge userChallenge = roundRecord.getUserChallenge();
User user = userChallenge.getUser();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.hrr.backend.domain.user.entity.User;
import com.hrr.backend.domain.verification.entity.Verification;


public interface WeakVerificationReportRepository extends JpaRepository<WeakVerificationReport, Long> {

// 특정 라운드의 특정 챌린저의 부실인증 개수 조회
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ public void reportWeakVerification(User reporter,Long verificationId) {
Verification targetVerification = verificationRepository.findByIdWithPessimisticLock(verificationId)
.orElseThrow(() -> new GlobalException(ErrorCode.VERIFICATION_NOT_FOUND));

// 삭제된 인증글은 존재하지 않는 것으로 처리
// soft delete로 행이 남아있으므로 명시적으로 걸러야 신고가 들어오지 않는다.
if (targetVerification.isDeleted()) {
throw new GlobalException(ErrorCode.VERIFICATION_NOT_FOUND);
}

// 차단 확인 (가장 먼저!)
// 이미 게시글 신고 5회 누적으로 차단된 글이라면 다른 검증을 할 필요도 없이 바로 예외를 던짐
if (VerificationStatus.BLOCKED.equals(targetVerification.getStatus())) {
Expand Down Expand Up @@ -122,6 +128,12 @@ public void reportVerificationPost(User reporter, ReportRequestDto request) {
Verification verification = verificationRepository.findByIdWithPessimisticLock(request.getTargetId())
.orElseThrow(() -> new GlobalException(ErrorCode.VERIFICATION_NOT_FOUND));

// 삭제된 인증글은 존재하지 않는 것으로 처리
// soft delete로 행이 남아있으므로 명시적으로 걸러야 신고가 들어오지 않는다.
if (verification.isDeleted()) {
throw new GlobalException(ErrorCode.VERIFICATION_NOT_FOUND);
}

// 차단 확인 (가장 먼저!)
// 이미 차단된 글이라면 다른 검증을 할 필요도 없이 바로 예외를 던집니다.
if (VerificationStatus.BLOCKED.equals(verification.getStatus())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ public void increaseVerificationCount() {
this.verificationCount++;
}

// 인증글 삭제 시 인증 횟수를 감소
// 기존 데이터에 삭제분이 반영되어 있지 않아 음수가 발생할 수 있으므로 하한(0) 처리
public void decreaseVerificationCount() {
if (this.verificationCount > 0) {
this.verificationCount--;
}
}

public void updateFinalRank(Integer rank) {
this.finalRank = rank;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class RoundRecordServiceImpl implements RoundRecordService {

private final WeakVerificationReportRepository weakVerificationReportRepository;

private final VerificationAbsenceLogRepository verificationAbsenceLogRepository;
private final VerificationAbsenceLogRepository verificationAbsenceLogRepository;

private final UserChallengeRepository userChallengeRepository;

Expand All @@ -39,13 +39,10 @@ public void synchronizeWarnCount(Long roundRecordId) {
RoundRecord roundRecord = roundRecordRepository.findByIdWithPessimisticLock(roundRecordId)
.orElseThrow(() -> new GlobalException(ErrorCode.ROUND_RECORD_NOT_FOUND));

// 부실 인증 신고 수와 미인증 로그 수 조회
long weakReportCount = weakVerificationReportRepository.countByRoundRecordId(roundRecordId);
long absenceCount = verificationAbsenceLogRepository.countByRoundRecordId(roundRecordId);

// 경고 횟수 계산: (부실 신고 / 3) + 미인증 횟수
int calculatedWarnCount = (int) (weakReportCount / 3) + (int) absenceCount;
// 부실 인증 신고 수만 조회
long weakReportCount = weakVerificationReportRepository.countByRoundRecordId(roundRecordId);

int calculatedWarnCount = (int) (weakReportCount / 3);
// 경고 횟수 동기화 (퇴출 기능 폐지로 KICKED 자동 전환은 더 이상 발생하지 않음)
roundRecord.synchronizeWarnCount(calculatedWarnCount);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,20 @@ public VerificationResponseDto.CreateResponseDto toResponseDto(Verification veri
*/
public VerificationResponseDto.MyProfileDto toMyProfileDto(
UserChallenge userChallenge,
Long totalVerificationCount,
Integer verificationCount,
Integer weakVerificationCount,
Integer warningCount,
Long currentRoundSequence,
SliceResponseDto<VerificationResponseDto.FeedDto> verifications
) {
return VerificationResponseDto.MyProfileDto.builder()
.nickname(userChallenge.getUser().getDisplayNickname())
.totalVerificationCount(totalVerificationCount)
.warningCount(userChallenge.getKickWarnings())
// TODO: 프론트 전환 완료 확인 후 DTO 필드와 함께 제거할 것.
.totalVerificationCount(verificationCount.longValue())
.verificationCount(verificationCount)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
// 현재 라운드 부실 인증 횟수
.weakVerificationCount(weakVerificationCount)
.warningCount(warningCount)
.currentRoundSequence(currentRoundSequence)
.verifications(verifications)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,18 @@ public static class MyProfileDto {
@Schema(description = "사용자 닉네임", example = "해빗")
private String nickname;

@Schema(description = "누적 인증 횟수 (해당 챌린지 내 전체)", example = "15")
// TODO: 하위 호환용 deprecated 필드
@Deprecated
@Schema(description = "[Deprecated] verificationCount를 사용하세요. 현재 진행 중인 라운드의 인증 횟수", example = "5")
private Long totalVerificationCount;

@Schema(description = "누적 경고 횟수", example = "1")
@Schema(description = "현재 진행 중인 라운드의 인증 횟수", example = "5")
private Integer verificationCount;

@Schema(description = "현재 진행 중인 라운드의 부실 인증 횟수 (0~2)", example = "2")
private Integer weakVerificationCount;

@Schema(description = "현재 진행 중인 라운드의 경고 횟수 (부실 인증 3회당 1회)", example = "1")
private Integer warningCount;

@Schema(description = "현재 참여 중인 라운드 순서 (예: 1회차, 2회차...)", example = "3")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import lombok.*;
import org.hibernate.annotations.ColumnDefault;

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

Expand Down Expand Up @@ -67,7 +68,10 @@ public class Verification extends BaseEntity {
private Boolean isQuestion;

@Enumerated(EnumType.STRING)
private VerificationStatus status; // TEMPORARY, COMPLETED, BLOCKED
private VerificationStatus status; // TEMPORARY, COMPLETED, BLOCKED, DELETED

@Column(name = "deleted_at")
private LocalDateTime deletedAt;

@Column(nullable = false)
@ColumnDefault("false")
Expand Down Expand Up @@ -138,6 +142,19 @@ public static Verification createPhotoVerification(

// === 비즈니스 로직 메서드 ===

// 인증글 soft delete
// 신고 이력은 보존해야 하므로 상태만 변경
// 같은 날 재인증은 uk_user_challenge_date 유니크 제약에 의해 계속 차단
public void softDelete(LocalDateTime deletedAt) {
this.status = VerificationStatus.DELETED;
this.deletedAt = deletedAt;
}

// [추가] 사용자에게 노출되지 않아야 하는 삭제 상태인지 여부
public boolean isDeleted() {
return this.status == VerificationStatus.DELETED;
}

public void resolve() {
this.isResolved = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
public enum VerificationStatus {
TEMPORARY,
COMPLETED,
BLOCKED
BLOCKED,
// 부실인증 신고 이력 보존을 위함
DELETED
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,23 @@ boolean existsTodayVerification(
@Param("endOfDay") LocalDateTime endOfDay
);

// 해당 인증 시간대에 인증 "이력"이 있는지 확인 (중복 인증 방지 전용)
// - existsTodayVerification : 지금 인증을 완료한 상태인가? (화면 표시용, COMPLETED만)
// - 이 메서드 : 이 시간대를 이미 사용했는가? (중복 방지용, 삭제분 포함)
@Query("""
SELECT COUNT(v) > 0
FROM Verification v
WHERE v.roundRecord.userChallenge.id = :userChallengeId
AND v.status <> com.hrr.backend.domain.verification.entity.enums.VerificationStatus.TEMPORARY
AND v.createdAt >= :startOfDay
AND v.createdAt <= :endOfDay
""")
boolean existsVerificationHistoryInWindow(
@Param("userChallengeId") Long userChallengeId,
@Param("startOfDay") LocalDateTime startOfDay,
@Param("endOfDay") LocalDateTime endOfDay
);

// 가장 최근 인증 날짜 조회 (COMPLETED 상태만)
@Query("SELECT MAX(v.createdAt) FROM Verification v " +
"JOIN v.roundRecord r " +
Expand Down Expand Up @@ -77,7 +94,7 @@ List<Verification> findWeeklyVerifications(
"JOIN FETCH uc.user " +
"WHERE v.roundId = :roundId " +
"AND v.userChallenge.id = :userChallengeId " +
"AND v.status != 'BLOCKED' " +
"AND v.status = 'COMPLETED' " +
"ORDER BY v.createdAt DESC")
List<Verification> findByRoundIdAndUserChallengeId(
@Param("roundId") Long roundId,
Expand All @@ -91,7 +108,7 @@ List<Verification> findByRoundIdAndUserChallengeId(
"JOIN FETCH v.userChallenge uc " +
"JOIN FETCH uc.user " +
"WHERE v.roundId = :roundId " +
"AND v.status != 'BLOCKED' " +
"AND v.status = 'COMPLETED' " +
"ORDER BY v.createdAt DESC")
Page<Verification> findByRoundId(@Param("roundId") Long roundId, Pageable pageable);

Expand All @@ -101,7 +118,7 @@ List<Verification> findByRoundIdAndUserChallengeId(
@Query("SELECT v FROM Verification v " +
"JOIN FETCH v.userChallenge uc " +
"WHERE uc.user.id = :userId " +
"AND v.status != 'BLOCKED' " +
"AND v.status = 'COMPLETED' " +
"AND uc.challenge.id = :challengeId " +
"ORDER BY v.createdAt DESC")
Page<Verification> findByUserIdAndChallengeId(
Expand Down
Loading