This commit is contained in:
Bright 2025-08-19 12:07:36 +07:00
parent 8b7de2a0ba
commit 48e7aa0906

View file

@ -169,32 +169,32 @@ export class ApiWebServiceController extends Controller {
};
await this.apiHistoryRepository.save(history);
const results = data.map((item) => {
const flattenedItem: any = {};
// const results = data.map((item) => {
// const flattenedItem: any = {};
// Extract nested object properties to top level
Object.keys(item).forEach((key) => {
const value = item[key];
if (value && typeof value === "object") {
// if (Array.isArray(value) && value.length === 1) {
// // If array has single item, extract it as object
// Object.assign(flattenedItem, value[0]);
// } else
if (!Array.isArray(value)) {
// Merge nested object properties to top level
Object.assign(flattenedItem, value);
} else {
// Keep arrays with multiple items or empty arrays as is
flattenedItem[key] = value;
}
} else {
// Keep primitive values as is
flattenedItem[key] = value;
}
});
// // Extract nested object properties to top level
// Object.keys(item).forEach((key) => {
// const value = item[key];
// if (value && typeof value === "object") {
// // if (Array.isArray(value) && value.length === 1) {
// // // If array has single item, extract it as object
// // Object.assign(flattenedItem, value[0]);
// // } else
// if (!Array.isArray(value)) {
// // Merge nested object properties to top level
// Object.assign(flattenedItem, value);
// } else {
// // Keep arrays with multiple items or empty arrays as is
// flattenedItem[key] = value;
// }
// } else {
// // Keep primitive values as is
// flattenedItem[key] = value;
// }
// });
return flattenedItem;
});
return new HttpSuccess({ data: results, total });
// return flattenedItem;
// });
return new HttpSuccess({ data: data, total });
}
}