Skip to content

Commit 3297fb9

Browse files
authored
Dev > Main 브랜치 병합
1. 유저 정지 기간, 영구 정지 컬럼을 추가하였습니다. 2. 경고 횟수에 따른 계정정지 기능을 구현하였습니다. 통합 테스트 후 Main 브랜치로 병합합니다.
2 parents 762ad29 + c2b1f16 commit 3297fb9

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/main/java/hs/kr/backend/devpals/domain/report/service/ReportAdminService.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.springframework.stereotype.Service;
1919
import org.springframework.transaction.annotation.Transactional;
2020

21+
import java.time.LocalDateTime;
2122
import java.util.List;
2223

2324
@Service
@@ -84,11 +85,14 @@ public ResponseEntity<ApiResponse<Void>> imposeWarning(Long reportId, String tok
8485
UserEntity user = userRepository.findById(report.getReportTargetId())
8586
.orElseThrow(() -> new CustomException(ErrorException.USER_NOT_FOUND));
8687

87-
user.increaseWarning(); // 경고 +1
88-
report.impose(); // isImposed = true
88+
user.increaseWarning();
89+
user.applyBanIfNeededAfterWarning();
90+
91+
report.impose();
8992

9093
return ResponseEntity.ok(new ApiResponse<>(200, true, "경고 부여 성공", null));
9194
}
9295

9396

97+
9498
}

src/main/java/hs/kr/backend/devpals/domain/user/entity/UserEntity.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ public class UserEntity {
7777
@SQLRestriction("report_filter = 'USER'") // @Where 대신 @SQLRestriction 사용
7878
private List<ReportEntity> receivedReports = new ArrayList<>();
7979

80+
@Column
81+
private LocalDateTime bannedUntil; // 정지 만료일 (null이면 정지 아님)
82+
83+
@Column(nullable = false)
84+
private boolean isPermanentlyBanned = false; // 영구 정지 여부
85+
8086

8187
// 유저 업데이트
8288
public void updateUserInfo(String nickname, String bio, Boolean beginner,
@@ -133,4 +139,13 @@ public UserEntity(String email, String password, String nickname, Boolean beginn
133139
this.nickname = nickname;
134140
this.beginner = beginner;
135141
}
142+
143+
public void applyBanIfNeededAfterWarning() {
144+
if (this.warning == 3) {
145+
this.bannedUntil = LocalDateTime.now().plusDays(7);
146+
} else if (this.warning >= 5) {
147+
this.isPermanentlyBanned = true;
148+
this.bannedUntil = null;
149+
}
150+
}
136151
}

0 commit comments

Comments
 (0)