From 242223483d992cd88b03d46d47db657915ca49c8 Mon Sep 17 00:00:00 2001 From: ssw Date: Thu, 2 Jul 2026 12:46:21 +0800 Subject: [PATCH] =?UTF-8?q?R3.1=20=E4=BF=AE=E5=A4=8D:=20di=20update=20--re?= =?UTF-8?q?questMethod=20=E2=86=92=20--action=20=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E5=90=8D=E4=BF=AE=E6=AD=A3=20(2026-07-02)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit audit 2026-07-02 §role/print/di 报告 P0 #1: - 原 --requestMethod (HTTP verb GET/POST/PUT/DELETE) - 错位映射到 action (SQL 1=增 2=改 3=查 4=删) - Number('GET')=NaN, 每次 update 触发 修复: - 改 --action <1|2|3|4> 跟 create 命令对齐 - 删除原 --requestMethod 选项 + body.requestMethod - 跟 create 行为一致, 字段语义清晰 - 跟 web 端 type=1 显示 action 字段对应 审计: dacli/docs/cmd-review/role-print-di-audit-2026-07-02.md --- src/commands/di/update.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) 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,