|
@@ -124,11 +124,64 @@
|
|
|
'debug_step'
|
|
|
];
|
|
|
|
|
|
+ // 别名映射与安全取值(不改变原有流程,仅用于判定与展示)
|
|
|
+ const aliasMap = {
|
|
|
+ // 入口时间允许从 request_parameters.timestamp 回退
|
|
|
+ debug_entry_time: ['debug_si_init_call_time', 'request_parameters.timestamp'],
|
|
|
+ debug_method_entered: ['debug_method_entered', 'debug_method_enter_time'],
|
|
|
+ debug_stage: ['debug_handler_stage'],
|
|
|
+ debug_timestamp: ['debug_final_timestamp', 'timestamp'],
|
|
|
+ debug_step: ['debug_controller_step', 'debug_init_step']
|
|
|
+ };
|
|
|
+
|
|
|
+ function getByPath(obj, path) {
|
|
|
+ if (!obj || !path) return undefined;
|
|
|
+ if (!path.includes('.')) return obj[path];
|
|
|
+ const parts = path.split('.');
|
|
|
+ let cur = obj;
|
|
|
+ for (const p of parts) {
|
|
|
+ if (cur == null) return undefined;
|
|
|
+ cur = cur[p];
|
|
|
+ }
|
|
|
+ return cur;
|
|
|
+ }
|
|
|
+
|
|
|
+ function getField(data, key) {
|
|
|
+ const direct = getByPath(data, key);
|
|
|
+ if (direct !== undefined && direct !== null) return direct;
|
|
|
+ const aliases = aliasMap[key] || [];
|
|
|
+ for (const alt of aliases) {
|
|
|
+ const v = getByPath(data, alt);
|
|
|
+ if (v !== undefined && v !== null) return v;
|
|
|
+ }
|
|
|
+ // 特例:若无显式 entered,使用入口/请求时间存在性派生
|
|
|
+ if (key === 'debug_method_entered') {
|
|
|
+ const hasEntry = getByPath(data, 'debug_si_init_call_time') !== undefined
|
|
|
+ || getByPath(data, 'debug_entry_time') !== undefined
|
|
|
+ || getByPath(data, 'request_parameters.timestamp') !== undefined
|
|
|
+ || getByPath(data, 'timestamp') !== undefined;
|
|
|
+ if (hasEntry) return true;
|
|
|
+ }
|
|
|
+ // 特例:若无显式 stage,根据 success/code 派生
|
|
|
+ if (key === 'debug_stage') {
|
|
|
+ const success = getByPath(data, 'success');
|
|
|
+ if (success === true) return '成功返回';
|
|
|
+ if (success === false) return '失败返回';
|
|
|
+ const code = getByPath(data, 'code');
|
|
|
+ if (code !== undefined) return (code === 200) ? '成功返回' : '失败返回';
|
|
|
+ }
|
|
|
+ return undefined;
|
|
|
+ }
|
|
|
+
|
|
|
+ function hasField(data, key) {
|
|
|
+ return getField(data, key) !== undefined;
|
|
|
+ }
|
|
|
+
|
|
|
const presentFields = [];
|
|
|
const missingFields = [];
|
|
|
|
|
|
requiredDebugFields.forEach(field => {
|
|
|
- if (result[field] !== undefined && result[field] !== null) {
|
|
|
+ if (hasField(result, field)) {
|
|
|
presentFields.push(field);
|
|
|
} else {
|
|
|
missingFields.push(field);
|
|
@@ -151,7 +204,8 @@
|
|
|
if (presentFields.length > 0) {
|
|
|
report += `=== 存在的Debug字段 ===\n`;
|
|
|
presentFields.forEach(field => {
|
|
|
- report += `✅ ${field}: ${result[field]}\n`;
|
|
|
+ const value = getField(result, field);
|
|
|
+ report += `✅ ${field}: ${value}\n`;
|
|
|
});
|
|
|
report += `\n`;
|
|
|
}
|