fix(mining-admin-service): 审计日志失败不影响批量补发返回结果
批量补发实际操作完成后,即使审计日志创建失败也应返回成功响应。 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
8a47659c47
commit
134e45e0bf
|
|
@ -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": []
|
||||||
|
|
|
||||||
|
|
@ -167,23 +167,29 @@ 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] 记录审计日志...`);
|
||||||
await this.prisma.auditLog.create({
|
try {
|
||||||
data: {
|
await this.prisma.auditLog.create({
|
||||||
adminId,
|
data: {
|
||||||
action: 'CREATE',
|
adminId,
|
||||||
resource: 'BATCH_MINING',
|
action: 'CREATE',
|
||||||
resourceId: data.batchId,
|
resource: 'BATCH_MINING',
|
||||||
newValue: {
|
resourceId: data.batchId,
|
||||||
totalUsers: data.totalUsers,
|
newValue: {
|
||||||
successCount: data.successCount,
|
totalUsers: data.totalUsers,
|
||||||
failedCount: data.failedCount,
|
successCount: data.successCount,
|
||||||
totalAmount: data.totalAmount,
|
failedCount: data.failedCount,
|
||||||
reason: request.reason,
|
totalAmount: data.totalAmount,
|
||||||
|
reason: request.reason,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
});
|
||||||
});
|
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}`,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue