R3.1 修复: di update --requestMethod → --action 字段名修正 (2026-07-02)

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
This commit is contained in:
ssw committed 2026-07-02 12:46:21 +08:00
1 parent 2633d1dacc
commit 242223483d
1 file changed
+11 -5
+11 -5
View File
@@ -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 <n>', '中文名')
.option('--enCode <e>', '英文编码')
.option('--categoryId <c>', '分类 id')
.option('--requestMethod <m>', '请求方法 (GET/POST/PUT/DELETE)')
// v0.15+ (R3.1): action 是 SQL 动词 (1=增 2=改 3=查 4=删), 跟 create 命令对齐
.option('--action <a>', '动作 (type=1 必填): 1=增加 2=修改 3=查询 4=删除')
.option('--url <u>', '接口路径/URL')
.option('--expected-enCode <e>', 'v0.11e+ Phase A2: 校验 enCode 未变 (防 AI session 误覆盖)')
.option('--expected-state <s>', '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,