diff --git a/src/commands/di/update.ts b/src/commands/di/update.ts index da071b0..f1c283c 100644 --- a/src/commands/di/update.ts +++ b/src/commands/di/update.ts @@ -18,7 +18,10 @@ interface Opts { fullName?: string enCode?: string categoryId?: string - requestMethod?: string + // v0.15+ (R3.1): 字段名修正 — 原 requestMethod (HTTP verb) 跟 action (SQL verb) 错位映射 + // audit 2026-07-02 §role/print/di 报告: update 用 --requestMethod (HTTP) 但映射到 action (SQL 1=增/2=改/3=查/4=删), Number('GET')=NaN + // 修复: 改 --action 跟 create 命令对齐 + action?: string url?: string expectedEnCode?: string expectedState?: string @@ -33,7 +36,8 @@ export function buildDiUpdateCommand(): Command { .option('--fullName ', '中文名') .option('--enCode ', '英文编码') .option('--categoryId ', '分类 id') - .option('--requestMethod ', '请求方法 (GET/POST/PUT/DELETE)') + // v0.15+ (R3.1): action 是 SQL 动词 (1=增 2=改 3=查 4=删), 跟 create 命令对齐 + .option('--action ', '动作 (type=1 必填): 1=增加 2=修改 3=查询 4=删除') .option('--url ', '接口路径/URL') .option('--expected-enCode ', 'v0.11e+ Phase A2: 校验 enCode 未变 (防 AI session 误覆盖)') .option('--expected-state ', 'v0.11e+ Phase A2: 校验 enabledMark 未变') @@ -75,7 +79,8 @@ export function buildDiUpdateCommand(): Command { if (opts.fullName) body.fullName = opts.fullName if (opts.enCode) body.enCode = opts.enCode if (opts.categoryId) body.categoryId = opts.categoryId - if (opts.requestMethod) body.requestMethod = opts.requestMethod + // v0.15+ (R3.1): --action 改跟 create 对齐, 删 requestMethod + if (opts.action !== undefined) body.action = Number(opts.action) if (opts.url) body.url = opts.url log.info(`loadDataInterface.updateDataInterface (id=${opts.id})`) const r = (await loadDataInterface.updateDataInterface(body)) as { code?: number; msg?: string; data?: unknown } @@ -93,7 +98,7 @@ export function buildDiUpdateCommand(): Command { installAiHelpHook(cmd, { purpose: '数据接口修改 (改 schema/path/参数). PUT 语义, 未传字段保留原值. v0.11d+ 加 step machine 校验 (3 step 镜像 web dataInterface/Form.vue + 后端 DataInterfaceController.update, BS-47 唯一性预校验, 聚合错误)', required: { '--id': '数据接口 id' }, - optional: { '--fullName': '中文名', '--enCode': '英文编码', '--categoryId': '分类 id', '--requestMethod': '请求方法', '--url': '接口路径/URL', '--expected-enCode': '防 AI 误覆盖 (A2)', '--expected-state': '防 AI 误覆盖 (A2)', '--force': '跳过 dirty check (A2)' }, + optional: { '--fullName': '中文名', '--enCode': '英文编码', '--categoryId': '分类 id', '--action': '动作 (1=增 2=改 3=查 4=删, type=1 必填)', '--url': '接口路径/URL', '--expected-enCode': '防 AI 误覆盖 (A2)', '--expected-state': '防 AI 误覆盖 (A2)', '--force': '跳过 dirty check (A2)' }, example: 'dacli di update --id=123 --url=/api/new/path', source: { api: 'PUT /api/system/DataInterface/{id}', ref: 'web/.../api/systemData/dataInterface.ts updateDataInterface() (后端: jnpf/.../DataInterfaceController.java:292-311)' }, notes: [ @@ -151,7 +156,8 @@ async function runDiStepMachine( enCode: opts.enCode, category: opts.categoryId, type: orig.type !== undefined ? Number(orig.type) : undefined, - action: opts.requestMethod !== undefined ? Number(opts.requestMethod) : (orig.action as number | undefined), + // v0.15+ (R3.1): 字段名 action, 跟 create 对齐, Number(action) 合法 + action: opts.action !== undefined ? Number(opts.action) : (orig.action as number | undefined), enabledMark: orig.enabledMark !== undefined ? Number(orig.enabledMark) : undefined, sortCode: orig.sortCode !== undefined ? Number(orig.sortCode) : undefined, hasPage: orig.hasPage !== undefined ? Number(orig.hasPage) : undefined,