|
|
@ -380,7 +380,7 @@ export class TablesService { |
|
|
|
validatePayload('swagger.json#/components/schemas/TableReq', param.table); |
|
|
|
validatePayload('swagger.json#/components/schemas/TableReq', param.table); |
|
|
|
|
|
|
|
|
|
|
|
const tableCreatePayLoad: Omit<TableReqType, 'columns'> & { |
|
|
|
const tableCreatePayLoad: Omit<TableReqType, 'columns'> & { |
|
|
|
columns: (Omit<ColumnType, 'column_name' | 'title'> & { cn?: string })[]; |
|
|
|
columns: (ColumnType & { cn?: string })[]; |
|
|
|
} = { |
|
|
|
} = { |
|
|
|
...param.table, |
|
|
|
...param.table, |
|
|
|
}; |
|
|
|
}; |
|
|
@ -603,18 +603,20 @@ export class TablesService { |
|
|
|
tn: tableCreatePayLoad.table_name, |
|
|
|
tn: tableCreatePayLoad.table_name, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const columns: Array< |
|
|
|
let columns: Array< |
|
|
|
Omit<Column, 'column_name' | 'title'> & { |
|
|
|
Omit<Column, 'column_name' | 'title'> & { |
|
|
|
cn: string; |
|
|
|
cn: string; |
|
|
|
system?: boolean; |
|
|
|
system?: boolean; |
|
|
|
} |
|
|
|
} |
|
|
|
> = ( |
|
|
|
>; |
|
|
|
await sqlMgr.sqlOpPlus(source, 'columnList', { |
|
|
|
if (!source.isMeta()) { |
|
|
|
tn: tableCreatePayLoad.table_name, |
|
|
|
columns = ( |
|
|
|
schema: source.getConfig()?.schema, |
|
|
|
await sqlMgr.sqlOpPlus(source, 'columnList', { |
|
|
|
}) |
|
|
|
tn: tableCreatePayLoad.table_name, |
|
|
|
)?.data?.list; |
|
|
|
schema: source.getConfig()?.schema, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
)?.data?.list; |
|
|
|
|
|
|
|
} |
|
|
|
const tables = await Model.list({ |
|
|
|
const tables = await Model.list({ |
|
|
|
base_id: base.id, |
|
|
|
base_id: base.id, |
|
|
|
source_id: source.id, |
|
|
|
source_id: source.id, |
|
|
@ -625,21 +627,15 @@ export class TablesService { |
|
|
|
// todo: type correction
|
|
|
|
// todo: type correction
|
|
|
|
const result = await Model.insert(base.id, source.id, { |
|
|
|
const result = await Model.insert(base.id, source.id, { |
|
|
|
...tableCreatePayLoad, |
|
|
|
...tableCreatePayLoad, |
|
|
|
columns: columns.map((c, i) => { |
|
|
|
columns: tableCreatePayLoad.columns.map((c, i) => { |
|
|
|
const colMetaFromReq = param.table?.columns?.find( |
|
|
|
const colMetaFromDb = columns?.find((c1) => c.cn === c1.cn); |
|
|
|
(c1) => c.cn === c1.column_name, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
|
...colMetaFromReq, |
|
|
|
|
|
|
|
uidt: colMetaFromReq?.uidt || c.uidt || getColumnUiType(source, c), |
|
|
|
|
|
|
|
...c, |
|
|
|
...c, |
|
|
|
dtxp: [UITypes.MultiSelect, UITypes.SingleSelect].includes( |
|
|
|
uidt: c.uidt || getColumnUiType(source, colMetaFromDb || c), |
|
|
|
colMetaFromReq.uidt as any, |
|
|
|
...(colMetaFromDb || {}), |
|
|
|
) |
|
|
|
dtxp: colMetaFromDb?.dtxp ?? c.dtxp, |
|
|
|
? colMetaFromReq.dtxp |
|
|
|
title: c.title || getColumnNameAlias(c.cn, source), |
|
|
|
: c.dtxp, |
|
|
|
column_name: colMetaFromDb?.cn || c.cn || c.column_name, |
|
|
|
title: colMetaFromReq?.title || getColumnNameAlias(c.cn, source), |
|
|
|
|
|
|
|
column_name: c.cn, |
|
|
|
|
|
|
|
order: i + 1, |
|
|
|
order: i + 1, |
|
|
|
} as NormalColumnRequestType; |
|
|
|
} as NormalColumnRequestType; |
|
|
|
}), |
|
|
|
}), |
|
|
|