fix(mining-admin-service): 审计日志失败不影响批量补发返回结果

批量补发实际操作完成后,即使审计日志创建失败也应返回成功响应。

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-22 00:57:00 -08:00
parent 8a47659c47
commit 134e45e0bf
2 changed files with 23 additions and 16 deletions

View File

@ -797,7 +797,8 @@
"Bash(npm run lint)", "Bash(npm run lint)",
"Bash(ssh -o ProxyCommand=\"ssh -W %h:%p ceshi@103.39.231.231\" -o StrictHostKeyChecking=no ceshi@192.168.1.111 \"cat /home/ceshi/rwadurian/backend/services/mining-service/src/application/services/batch-mining.service.ts | head -250\")", "Bash(ssh -o ProxyCommand=\"ssh -W %h:%p ceshi@103.39.231.231\" -o StrictHostKeyChecking=no ceshi@192.168.1.111 \"cat /home/ceshi/rwadurian/backend/services/mining-service/src/application/services/batch-mining.service.ts | head -250\")",
"Bash(ssh -o ProxyCommand=\"ssh -W %h:%p ceshi@103.39.231.231\" -o StrictHostKeyChecking=no ceshi@192.168.1.111 \"docker logs rwa-mining-admin-service --tail 50 2>&1 | grep ''第一条数据\\\\|最后一条数据''\")", "Bash(ssh -o ProxyCommand=\"ssh -W %h:%p ceshi@103.39.231.231\" -o StrictHostKeyChecking=no ceshi@192.168.1.111 \"docker logs rwa-mining-admin-service --tail 50 2>&1 | grep ''第一条数据\\\\|最后一条数据''\")",
"Bash(npx xlsx-cli 挖矿.xlsx)" "Bash(npx xlsx-cli 挖矿.xlsx)",
"Bash(DATABASE_URL=\"postgresql://postgres:password@localhost:5432/mining_db?schema=public\" npx prisma migrate dev:*)"
], ],
"deny": [], "deny": [],
"ask": [] "ask": []

View File

@ -167,8 +167,9 @@ export class BatchMiningService {
// mining-service 使用 TransformInterceptor 包装响应为 { success, data, timestamp } // mining-service 使用 TransformInterceptor 包装响应为 { success, data, timestamp }
const data = result.data || result; const data = result.data || result;
// 记录审计日志 // 记录审计日志(失败不影响返回结果,因为实际操作已完成)
this.logger.log(`[execute] 记录审计日志...`); this.logger.log(`[execute] 记录审计日志...`);
try {
await this.prisma.auditLog.create({ await this.prisma.auditLog.create({
data: { data: {
adminId, adminId,
@ -184,6 +185,11 @@ export class BatchMiningService {
}, },
}, },
}); });
this.logger.log(`[execute] 审计日志记录成功`);
} catch (auditError) {
// 审计日志失败不应该影响返回结果,因为批量补发已经成功执行
this.logger.error(`[execute] 审计日志记录失败(不影响返回结果):`, auditError);
}
this.logger.log( this.logger.log(
`[execute] 批量补发执行成功: admin=${adminId}, total=${data.totalUsers}, success=${data.successCount}, amount=${data.totalAmount}`, `[execute] 批量补发执行成功: admin=${adminId}, total=${data.totalUsers}, success=${data.successCount}, amount=${data.totalAmount}`,