fix(mining-admin): 解包 mining-service 响应的 TransformInterceptor 包装
mining-service 使用 TransformInterceptor 将所有响应包装为 { success, data, timestamp } 结构,
mining-admin-service 需要从 result.data 中提取实际数据。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
a02813a8ea
commit
30a82f09f3
|
|
@ -69,8 +69,10 @@ export class BatchMiningService {
|
|||
);
|
||||
}
|
||||
|
||||
this.logger.log(`[getStatus] 成功获取状态: hasExecuted=${result.hasExecuted}`);
|
||||
return result;
|
||||
// mining-service 使用 TransformInterceptor 包装响应为 { success, data, timestamp }
|
||||
const data = result.data || result;
|
||||
this.logger.log(`[getStatus] 成功获取状态: hasExecuted=${data.hasExecuted}`);
|
||||
return data;
|
||||
} catch (error) {
|
||||
if (error instanceof HttpException) {
|
||||
throw error;
|
||||
|
|
@ -102,7 +104,6 @@ export class BatchMiningService {
|
|||
|
||||
this.logger.log(`[preview] 响应状态码: ${response.status}`);
|
||||
const result = await response.json();
|
||||
this.logger.log(`[preview] 响应数据概要: totalBatches=${result.totalBatches}, totalUsers=${result.totalUsers}, grandTotalAmount=${result.grandTotalAmount}`);
|
||||
|
||||
if (!response.ok) {
|
||||
this.logger.error(`[preview] 请求失败: ${result.message || '未知错误'}`);
|
||||
|
|
@ -112,8 +113,11 @@ export class BatchMiningService {
|
|||
);
|
||||
}
|
||||
|
||||
// mining-service 使用 TransformInterceptor 包装响应为 { success, data, timestamp }
|
||||
const data = result.data || result;
|
||||
this.logger.log(`[preview] 响应数据概要: totalBatches=${data.totalBatches}, totalUsers=${data.totalUsers}, grandTotalAmount=${data.grandTotalAmount}`);
|
||||
this.logger.log(`[preview] 预览成功`);
|
||||
return result;
|
||||
return data;
|
||||
} catch (error) {
|
||||
if (error instanceof HttpException) {
|
||||
throw error;
|
||||
|
|
@ -159,6 +163,9 @@ export class BatchMiningService {
|
|||
);
|
||||
}
|
||||
|
||||
// mining-service 使用 TransformInterceptor 包装响应为 { success, data, timestamp }
|
||||
const data = result.data || result;
|
||||
|
||||
// 记录审计日志
|
||||
this.logger.log(`[execute] 记录审计日志...`);
|
||||
await this.prisma.auditLog.create({
|
||||
|
|
@ -166,22 +173,22 @@ export class BatchMiningService {
|
|||
adminId,
|
||||
action: 'CREATE',
|
||||
resource: 'BATCH_MINING',
|
||||
resourceId: result.batchId,
|
||||
resourceId: data.batchId,
|
||||
newValue: {
|
||||
totalUsers: result.totalUsers,
|
||||
successCount: result.successCount,
|
||||
failedCount: result.failedCount,
|
||||
totalAmount: result.totalAmount,
|
||||
totalUsers: data.totalUsers,
|
||||
successCount: data.successCount,
|
||||
failedCount: data.failedCount,
|
||||
totalAmount: data.totalAmount,
|
||||
reason: request.reason,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
this.logger.log(
|
||||
`[execute] 批量补发执行成功: admin=${adminId}, total=${result.totalUsers}, success=${result.successCount}, amount=${result.totalAmount}`,
|
||||
`[execute] 批量补发执行成功: admin=${adminId}, total=${data.totalUsers}, success=${data.successCount}, amount=${data.totalAmount}`,
|
||||
);
|
||||
|
||||
return result;
|
||||
return data;
|
||||
} catch (error) {
|
||||
if (error instanceof HttpException) {
|
||||
throw error;
|
||||
|
|
@ -216,7 +223,6 @@ export class BatchMiningService {
|
|||
}
|
||||
|
||||
const result = await response.json();
|
||||
this.logger.log(`[getExecution] 响应数据概要: id=${result.id}, totalUsers=${result.totalUsers}`);
|
||||
|
||||
if (!response.ok) {
|
||||
this.logger.error(`[getExecution] 请求失败: ${result.message || '未知错误'}`);
|
||||
|
|
@ -226,8 +232,11 @@ export class BatchMiningService {
|
|||
);
|
||||
}
|
||||
|
||||
// mining-service 使用 TransformInterceptor 包装响应为 { success, data, timestamp }
|
||||
const data = result.data || result;
|
||||
this.logger.log(`[getExecution] 响应数据概要: id=${data.id}, totalUsers=${data.totalUsers}`);
|
||||
this.logger.log(`[getExecution] 成功获取执行记录`);
|
||||
return result;
|
||||
return data;
|
||||
} catch (error) {
|
||||
if (error instanceof HttpException) {
|
||||
throw error;
|
||||
|
|
|
|||
Loading…
Reference in New Issue