fix: revert AdminAuditService to PrismaService — queue not available in auth module
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 41s

This commit is contained in:
WangDL 2026-05-23 19:57:43 +08:00
parent b5d5fb357f
commit 7a31bd3702

View File

@ -1,5 +1,5 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { QueueService } from '../../infrastructure/queue/queue.service'; import { PrismaService } from '../../infrastructure/database/prisma.service';
export interface AuditLogInput { export interface AuditLogInput {
adminUserId: string; adminUserId: string;
@ -16,21 +16,22 @@ export interface AuditLogInput {
@Injectable() @Injectable()
export class AdminAuditService { export class AdminAuditService {
constructor(private readonly queue: QueueService) {} constructor(private readonly prisma: PrismaService) {}
/** Async audit log via BullMQ — never blocks the main operation */
async log(input: AuditLogInput) { async log(input: AuditLogInput) {
await this.queue.add('audit-logs', { await this.prisma.adminAuditLog.create({
adminUserId: input.adminUserId, data: {
action: input.action, adminUserId: input.adminUserId,
resourceType: input.resourceType ?? null, action: input.action,
resourceId: input.resourceId ?? null, resourceType: input.resourceType ?? null,
beforeJson: input.beforeJson ?? null, resourceId: input.resourceId ?? null,
afterJson: input.afterJson ?? null, beforeJson: input.beforeJson ?? null,
ip: input.ip ?? null, afterJson: input.afterJson ?? null,
userAgent: input.userAgent ?? null, ip: input.ip ?? null,
riskLevel: input.riskLevel ?? this.defaultRisk(input.action), userAgent: input.userAgent ?? null,
reason: input.reason ?? null, riskLevel: input.riskLevel ?? this.defaultRisk(input.action),
reason: input.reason ?? null,
},
}); });
} }