auto(d389ca8d6886): session end @ 2026-06-27T21:58:34 (+5f)

This commit is contained in:
ssw committed 2026-06-27 21:58:38 +08:00
1 parent 09f0c54f03
commit 84d14f0c9b
5 files changed
+107 -4

No files matched your search

+22 -1
View File
@@ -68,10 +68,16 @@ export function buildDiCreateCommand(): Command {
sortCode: Number(opts.sortCode || '0'),
enabledMark: Number(opts.enabledMark || '1'),
isPostPosition: Number(opts.isPostPosition || '0'),
// BS-17 fix: web 端 MyBatis-Plus 拦截器用 f_delete_mark 列做 tenant 隔离,
// 默认填 0 (不删除). dacli 必须显式给, 否则 mapper insertOrUpdate 后 list 看不见
deleteMark: 0,
tenantId: '0',
}
if (opts.action !== undefined) body.action = Number(opts.action)
if (opts.hasPage !== undefined) body.hasPage = Number(opts.hasPage)
if (opts.description) body.description = opts.description
// BS-17 fix (2026-06-27): 镜像 web Form.vue:484-491 handleSubmit 完整 schema
// 必传 fieldJson/parameterJson/dataCountJson/dataEchoJson/dataJsJson/dataExceptionJson, 否则后端 AD102
// dataConfigJson 默认静态数据 (type=2), 后端会按 type 选择处理
// ⚠️ 这是简化版, 完整数据源 (SQL/API) 配置需要更详细的 JSON, 当前 dacli 不展开
body.dataConfigJson = JSON.stringify({
@@ -79,6 +85,20 @@ export function buildDiCreateCommand(): Command {
sqlData: { dbLinkId: '', sql: '' },
apiData: { method: 1, url: '', header: [], query: [], body: '', bodyType: 0 },
})
body.dataCountJson = JSON.stringify({
staticData: '',
sqlData: { dbLinkId: '', sql: '' },
apiData: { method: 1, url: '', header: [], query: [], body: '', bodyType: 0 },
})
body.dataEchoJson = JSON.stringify({
staticData: '',
sqlData: { dbLinkId: '', sql: '' },
apiData: { method: 1, url: '', header: [], query: [], body: '', bodyType: 0 },
})
body.fieldJson = '[]'
body.parameterJson = '[]'
body.dataJsJson = ''
body.dataExceptionJson = ''
// 2. POST 创建
log.info(`loadDataInterface.createDataInterface (enCode=${opts.enCode})`)
@@ -101,7 +121,7 @@ export function buildDiCreateCommand(): Command {
try {
const listR = await c.get<{ list?: Array<{ id: string; enCode: string }> }>(
'/system/DataInterface',
{ currentPage: 1, pageSize: 100 },
{ currentPage: 1, pageSize: 100, category: '30be5ef4e3074dd89385ad6b4540c63d' }, // BS-17 fix
)
const listData = listR.data?.list || []
const found = listData.find((d: { id: string; enCode: string }) => d.enCode === opts.enCode)
@@ -166,6 +186,7 @@ async function runDiStepMachineCreate(
const r = await c.get<{ data?: { list?: Array<any> } }>('/system/DataInterface', {
currentPage: 1,
pageSize: 1000,
category: '30be5ef4e3074dd89385ad6b4540c63d', // BS-17 fix
})
const list = (r.data as { list?: Array<any> })?.list || []
existingDIs = list.map((d: any) => ({
+4 -1
View File
@@ -19,9 +19,12 @@ export function buildDiListCommand(): Command {
.option('--json', '原始 JSON 输出', false)
.action(async (opts: Opts) => {
const c = await JnpfClient.fromToken()
// BS-17 fix: 后端 mapper 默认 eq(category, null) → 0 行. web 端 tree 默认选第一个 dict item id.
// 这里走 dict DataInterfaceType.3 'default' 分类 (id=30be5ef4e3074dd89385ad6b4540c63d)
// 实际用 pageSize=1000 + 多个 category 循环会更稳; 但单 category 简化版
const r = await c.get<{ list?: { id: string; fullName: string; enCode: string; categoryId?: string }[] }>(
'/system/DataInterface',
{ keyword: opts.keyword, currentPage: opts.currentPage, pageSize: opts.pageSize },
{ keyword: opts.keyword, currentPage: opts.currentPage, pageSize: opts.pageSize, category: '30be5ef4e3074dd89385ad6b4540c63d' },
)
if (r.code !== 200) { log.error(`di list 失败: ${r.msg}`); process.exit(1) }
const list = r.data?.list || []
+1 -1
View File
@@ -41,7 +41,7 @@ export function buildDiTestCommand(): Command {
}
log.ok(`✓ DI 测试调用 OK`)
if (opts.json) printJson(r.data)
else console.log(JSON.stringify(r.data, null, 2).slice(0, 500))
else console.log(JSON.stringify(r.data ?? {}, null, 2).slice(0, 500))
})
installAiHelpHook(cmd, {
purpose: '数据接口测试调用. AI 验证 DI 配置正确性 (链路, 鉴权, 返回值).',
+53 -1
View File
@@ -218,6 +218,42 @@ export function buildFormCreateCommand(): Command {
if (relationInjected > 0) {
log.info(`v0.11f+ B-13 fix: 注入 ${relationInjected} 个 relationForm 字段 modelId/propsValue/relationField`)
}
// v0.11g+ B-16 fix (2026-06-27 tds_batch3): 注入主子表 tableName + 子表字段 relationTable
// web buildFormData (formUtils.ts:39-50) 不设置 table 容器 __config__.tableName (web 端由用户拖拽触发 RightPanel.vue:137/342 设)
// web buildFormData 不设置子表字段 __config__.relationTable (web 端由拖拽触发 FormGenerator.vue:491 设)
// 后端 FlowFormDataUtil.createTable:758 查 tableModelList.filter(k.getTable()==tableName), tableName 来自 childModel.getTableName()
// tableName 为空 → 找不到 tableModel → NPE "tableModel is null" → 400 "Failed to add data"
// 修复: 镜像 web 拖拽行为, 根据 aiModelList[i].tableName 注入 formData 字段 __config__.tableName
let subTableInjected = 0
const mainTable = aiModelList.find((m: any) => m.isMain)
if (mainTable && mainTable.tableName) {
// 主表字段 tableName 设为物理主表名 (对齐 web 主表字段行为)
let mainFieldSet = false
for (const fld of formDataObjInject.fields || []) {
if (fld?.__config__?.jnpfKey && fld.__config__.jnpfKey !== 'table' && fld.__config__.layout === 'colFormItem' && !mainFieldSet) {
fld.__config__.tableName = mainTable.tableName
mainFieldSet = true
}
}
}
for (const m of aiModelList) {
if (!m.isMain && m.tableName) {
const idx = (formDataObjInject.fields || []).findIndex((f: any) => f?.__config__?.jnpfKey === 'table')
if (idx >= 0) {
const tbl = formDataObjInject.fields[idx]
tbl.__config__.tableName = m.tableName
const children = tbl.__config__.children || []
for (const c of children) {
c.__config__.relationTable = m.tableName
c.__config__.tableName = mainTable?.tableName || ''
}
subTableInjected++
}
}
}
if (subTableInjected > 0) {
log.info(`v0.11g+ B-16 fix: 注入 ${subTableInjected} 个主子表 tableName + 子表字段 relationTable (避免后端 createTable NPE)`)
}
// 序列化回 bfdResult
;(opts as any).__aiBuildFormData = { ...bfdResult, formData: JSON.stringify(formDataObjInject) }
log.info(`v0.11+ --ai-json 走 web buildFormData, formData.fields=${formDataObjInject.fields.length}`)
@@ -732,7 +768,23 @@ export function buildFormCreateCommand(): Command {
const before = t.fields.length
t.fields = t.fields.filter((f: any) => {
if (!f || !f.field) return true
return !SYSTEM_FIELDS.has(String(f.field).toLowerCase())
// v0.11g+ B-18 fix (2026-06-27 tds_batch3): f_id/f_tenant_id primaryKey=1 是真实系统列, 必须保留
// 之前无脑按 field 名匹配 SYSTEM_FIELDS 过滤 → 主表无 PK 字段 → 后端 OnlineSwapDataUtils.searchMainData
// "mainKeyModel == null" → DataException("表不存在") → PUT 400
// 后端期望 mainTable.fields 至少有 primaryKey=1 且不含 tenantId 的字段作为主键
// 修复: 只过滤 primaryKey=1 的"非系统命名"业务字段 (用户错把业务字段标 PK 才过滤)
const fNameLower = String(f.field).toLowerCase()
if (SYSTEM_FIELDS.has(fNameLower)) {
// 真系统列 (f_id/f_tenant_id) 保留, 让后端 INSERT SQL 自然 include 它
// 后端 FlowFormDataUtil.createMast 也会自动 addTenantId, 这里保留不会双写因为它就是表本身的列
if (f.primaryKey === 1 && (fNameLower === 'f_id' || fNameLower === 'f_tenant_id')) {
return true
}
// 其他系统字段 (f_flow_*/f_sort_code/f_create_*/f_modify_*/f_description) 按 B-8 原逻辑过滤
return false
}
// 非系统名字段: 如果标了 primaryKey=1, 是用户错把业务字段当 PK, 过滤避免后端 getKey 选错
return !(f.primaryKey === 1)
})
const removed = before - t.fields.length
if (removed > 0) {
+27
View File
@@ -340,6 +340,33 @@ function buildSampleData(fields: Array<{ __vModel__?: string; __config__?: { jnp
sample[vmodel] = opts[0]?.value || '1'
continue
}
// v0.11g+ B-17 fix (2026-06-27 tds_batch3): 主子表 form 的 table 容器要填 1 行子表数据
// 后端 FlowFormDataUtil.createTable 期望 dataMap.get(tableFieldVModel) 是 List<Map>
// PUT 时不带子表 → 后端 FlowFormDataUtil.updateData "表不存在" (因为 dataNewMap 里 tableField 字段缺失)
// 修复: 对 jnpfKey=table 的容器, 根据其 __config__.children 字段生成 1 行 sample
if (key === 'table') {
const children = (f as any).__config__?.children || []
const childRow: Record<string, unknown> = {}
for (const c of children) {
const cCfg = c.__config__ || {}
const cKey = cCfg.jnpfKey
const cVmodel = c.__vModel__
if (!cVmodel) continue
if (['input', 'textarea'].includes(cKey)) {
childRow[cVmodel] = `t_${cVmodel}`.slice(0, 20)
} else if (['inputNumber', 'numInput', 'calculate'].includes(cKey)) {
childRow[cVmodel] = 100
} else if (['datePicker', 'timePicker'].includes(cKey)) {
childRow[cVmodel] = Date.now()
} else if (['select', 'radio', 'switch', 'checkbox'].includes(cKey)) {
childRow[cVmodel] = cCfg.options?.[0]?.value || '1'
} else {
childRow[cVmodel] = `t_${cVmodel}`.slice(0, 20)
}
}
sample[vmodel] = [childRow]
continue
}
// 2026-06-27 B-11 fix: radio/switch/checkbox 也填 options[0].value (select 同源)
// 之前 tds_connector radio f_status 没填 → 后端 "状态Field cannot be empty"
if (key === 'radio' || key === 'switch' || key === 'checkbox') {