init: UserBaseService (backend + deploy + scripts)
ci-userbase-service / build-and-push (push) Successful in 40s
ci-userbase-service / build-and-push (push) Successful in 40s
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package com.yunhai.userbase.task;
|
||||
|
||||
import com.yunhai.userbase.service.ISysOperationLogService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 操作日志定时清理任务。<br>
|
||||
* 每日凌晨 3 点执行:一般日志(level=3)保留一年、重要(level=1)/次要(level=2)日志保留三年。<br>
|
||||
* 如需「删除前归档」,可在 {@code ISysOperationLogService.cleanupExpired} 中扩展归档逻辑。<br>
|
||||
*
|
||||
* @author chenx
|
||||
* @date 2026/7/28
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class OperationLogCleanupTask {
|
||||
|
||||
@Autowired
|
||||
private ISysOperationLogService sysOperationLogService;
|
||||
|
||||
@Scheduled(cron = "0 0 3 * * ?")
|
||||
public void run() {
|
||||
try {
|
||||
long deleted = sysOperationLogService.cleanupExpired();
|
||||
log.info("操作日志定时清理完成, 删除{}条", deleted);
|
||||
} catch (Exception e) {
|
||||
log.error("操作日志定时清理失败", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user