|
@@ -164,6 +164,52 @@
|
|
<script>
|
|
<script>
|
|
const API_BASE_URL = 'http://localhost:8321/api/entry/workinjury';
|
|
const API_BASE_URL = 'http://localhost:8321/api/entry/workinjury';
|
|
|
|
|
|
|
|
+ // 共享别名映射与取值工具(供所有函数使用)
|
|
|
|
+ const __aliasMap = {
|
|
|
|
+ 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(obj, key) {
|
|
|
|
+ const direct = __getByPath(obj, key);
|
|
|
|
+ if (direct !== undefined && direct !== null) return direct;
|
|
|
|
+ const aliases = __aliasMap[key] || [];
|
|
|
|
+ for (const alt of aliases) {
|
|
|
|
+ const v = __getByPath(obj, alt);
|
|
|
|
+ if (v !== undefined && v !== null) return v;
|
|
|
|
+ }
|
|
|
|
+ if (key === 'debug_method_entered') {
|
|
|
|
+ const hasEntry = __getByPath(obj, 'debug_si_init_call_time') !== undefined
|
|
|
|
+ || __getByPath(obj, 'debug_entry_time') !== undefined
|
|
|
|
+ || __getByPath(obj, 'request_parameters.timestamp') !== undefined
|
|
|
|
+ || __getByPath(obj, 'timestamp') !== undefined;
|
|
|
|
+ if (hasEntry) return true;
|
|
|
|
+ }
|
|
|
|
+ if (key === 'debug_stage') {
|
|
|
|
+ const success = __getByPath(obj, 'success');
|
|
|
|
+ if (success === true) return '成功返回';
|
|
|
|
+ if (success === false) return '失败返回';
|
|
|
|
+ const code = __getByPath(obj, 'code');
|
|
|
|
+ if (code !== undefined) return (code === 200) ? '成功返回' : '失败返回';
|
|
|
|
+ }
|
|
|
|
+ return undefined;
|
|
|
|
+ }
|
|
|
|
+
|
|
// 通用API调用函数
|
|
// 通用API调用函数
|
|
async function callAPI(requestData) {
|
|
async function callAPI(requestData) {
|
|
try {
|
|
try {
|
|
@@ -192,6 +238,9 @@
|
|
|
|
|
|
// 检查debug信息是否完整
|
|
// 检查debug信息是否完整
|
|
function checkDebugInfo(data, testName) {
|
|
function checkDebugInfo(data, testName) {
|
|
|
|
+ function hasField(obj, key) {
|
|
|
|
+ return __getField(obj, key) !== undefined;
|
|
|
|
+ }
|
|
const requiredFields = [
|
|
const requiredFields = [
|
|
'debug_entry_time',
|
|
'debug_entry_time',
|
|
'debug_method_entered',
|
|
'debug_method_entered',
|
|
@@ -204,7 +253,7 @@
|
|
const presentFields = [];
|
|
const presentFields = [];
|
|
|
|
|
|
requiredFields.forEach(field => {
|
|
requiredFields.forEach(field => {
|
|
- if (data[field] !== undefined && data[field] !== null) {
|
|
|
|
|
|
+ if (hasField(data, field)) {
|
|
presentFields.push(field);
|
|
presentFields.push(field);
|
|
} else {
|
|
} else {
|
|
missingFields.push(field);
|
|
missingFields.push(field);
|
|
@@ -248,7 +297,7 @@
|
|
|
|
|
|
resultText += `=== 存在的Debug字段 ===\n`;
|
|
resultText += `=== 存在的Debug字段 ===\n`;
|
|
debugCheck.presentFields.forEach(field => {
|
|
debugCheck.presentFields.forEach(field => {
|
|
- resultText += `${field}: ${apiResult.data[field]}\n`;
|
|
|
|
|
|
+ resultText += `${field}: ${__getField(apiResult.data, field)}\n`;
|
|
});
|
|
});
|
|
|
|
|
|
if (debugCheck.missingFields.length > 0) {
|
|
if (debugCheck.missingFields.length > 0) {
|