feat: 完善后台导入日志权限与备份恢复

This commit is contained in:
Nixevol
2026-07-04 09:06:35 +08:00
parent 5ae3b12fff
commit d484da3862
61 changed files with 2743 additions and 436 deletions
@@ -0,0 +1,23 @@
import { Injectable, Logger } from '@nestjs/common';
import { Cron, CronExpression } from '@nestjs/schedule';
import { SettingsService } from '../settings/settings.service';
import { OperationLogService } from './operation-log.service';
@Injectable()
export class OperationLogRetentionService {
private readonly logger = new Logger(OperationLogRetentionService.name);
constructor(
private readonly settings: SettingsService,
private readonly logs: OperationLogService,
) {}
@Cron(CronExpression.EVERY_DAY_AT_4AM)
async cleanup(): Promise<void> {
const raw = await this.settings.get('operationLogRetentionDays');
const days = Number(raw ?? 365);
if (!days || days <= 0) return;
const count = await this.logs.cleanup(days);
this.logger.log(`操作日志清理完成:${count} 条,保留 ${days} 天`);
}
}