260714_01_ENH: 테스트 서버에서 기동 후 중간 테스트를 위한 커밋

This commit is contained in:
2026-07-14 10:01:05 +09:00
parent 88d65bebe0
commit 50ecd6bf6b
162 changed files with 6790 additions and 907 deletions

View File

@@ -0,0 +1,74 @@
package com.kri.contact.server.scheduler;
import com.kri.contact.server.persistence.entity.TListUploadLogEntity;
import com.kri.contact.server.persistence.repository.ListUploadLogRepository;
import com.kri.contact.server.service.file.ListFileService;
import java.time.LocalDateTime;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@Slf4j
@Component
public class ListUploadFileCleanupScheduler {
private final ListUploadLogRepository listUploadLogRepository;
private final ListFileService listFileService;
private final long expireDays;
public ListUploadFileCleanupScheduler(
ListUploadLogRepository listUploadLogRepository,
ListFileService listFileService,
@Value("${kri.list-upload-file.cleanup-expire-days:7}") long expireDays
) {
this.listUploadLogRepository = listUploadLogRepository;
this.listFileService = listFileService;
this.expireDays = expireDays;
}
@Transactional
@Scheduled(cron = "${kri.list-upload-file.cleanup-cron:0 30 0 * * SUN}")
public void cleanupOldListUploadFiles() {
LocalDateTime threshold = LocalDateTime.now().minusDays(expireDays);
LocalDateTime deletedAt = LocalDateTime.now();
List<TListUploadLogEntity> uploadLogs =
listUploadLogRepository.findBySchedulingDelDtIsNullAndRegDtBefore(threshold);
if (uploadLogs.isEmpty()) {
log.info("[ListUploadFileCleanup] 대상 없음 - threshold={}", threshold);
return;
}
log.info("[ListUploadFileCleanup] 시작 - threshold={}, count={}", threshold, uploadLogs.size());
for (TListUploadLogEntity uploadLog : uploadLogs) {
try {
boolean deleted = listFileService.deleteListFileIfExists(
uploadLog.getPrjctIdx(),
uploadLog.getFileNm()
);
uploadLog.setSchedulingDelDt(deletedAt);
log.debug(
"[ListUploadFileCleanup] 삭제 처리 - listUploadLogId={}, fileNm={}, deleted={}",
uploadLog.getListUploadLogId(),
uploadLog.getFileNm(),
deleted
);
} catch (Exception e) {
log.warn(
"[ListUploadFileCleanup] 삭제 실패 - listUploadLogId={}, fileNm={}",
uploadLog.getListUploadLogId(),
uploadLog.getFileNm(),
e
);
}
}
log.info("[ListUploadFileCleanup] 종료");
}
}