P0-8 修复: di/create+update 残留 c.get → webapi/getDataInterfaceList (2026-07-02)
audit 2026-07-02 §role/print/di 报告 P1 #5: - di/create.ts:165, 229 + di/update.ts:133 共 3 处 raw c.get('/system/DataInterface') - 跟其他 webapi 化文件不一致, 后端路径迁移时 raw call 不自动跟随 - webapi/di.ts 缺 getDataInterfaceList 暴露 (web 端有, dacli 没用) 修复: - webapi/di.ts 新加 getDataInterfaceList(params) 暴露 - 镜像 web getDataInterfaceList (page list, 跟 jnpf-web 的 /api/systemData) - di/create.ts + di/update.ts 3 处 c.get 改 getDataInterfaceList - 行为一致: 仍走 /api/system/DataInterface 端点, 但走 webapi 框架 - 后续后端路径变更时 webapi shim 自动跟随, 不需要 raw call 改动 - 提升 di webapi 引用 6/8 → 8/8 (100% 覆盖) 审计: dacli/docs/cmd-review/role-print-di-audit-2026-07-02.md §di 部分
This commit is contained in:
1 parent
cb343a6e51
commit
a0b2a0d038
3 files changed
+25
-14
No files matched your search
+10
-10
@@ -16,7 +16,7 @@ import { Command } from 'commander'
|
||||
import { JnpfClient } from '../../core/client.ts'
|
||||
import { installAiHelpHook } from '../../core/help.ts'
|
||||
import { log, printJson } from '../../core/log.ts'
|
||||
import { initWebapi, loadDataInterface } from '../../webapi/di.ts'
|
||||
import { initWebapi, loadDataInterface, getDataInterfaceList } from '../../webapi/di.ts' // v0.15+ (P0-8): getDataInterfaceList 替代 c.get
|
||||
import { validateDiUpdate, type DiOpts } from './_validate.ts'
|
||||
import { enhanceFromBackend, formatErrorLine } from '../_error_codes.ts'
|
||||
|
||||
@@ -160,13 +160,12 @@ export function buildDiCreateCommand(): Command {
|
||||
}
|
||||
let newId = (r.data as { id?: string })?.id
|
||||
if (!newId) {
|
||||
// 拉列表查新 ID
|
||||
// 拉列表查新 ID (v0.15+ 走 webapi, 替代 c.get)
|
||||
try {
|
||||
const listR = await c.get<{ list?: Array<{ id: string; enCode: string }> }>(
|
||||
'/system/DataInterface',
|
||||
{ currentPage: 1, pageSize: 100, category: opts.category }, // BS-17 fix: 用用户传的 category, 不硬编码
|
||||
)
|
||||
const listData = listR.data?.list || []
|
||||
const listR = (await getDataInterfaceList({
|
||||
currentPage: 1, pageSize: 100, category: opts.category, // BS-17 fix: 用用户传的 category, 不硬编码
|
||||
})) as { data?: { list?: Array<{ id: string; enCode: string }> } } | unknown
|
||||
const listData = (listR as { data?: { list?: Array<{ id: string; enCode: string }> } })?.data?.list || []
|
||||
const found = listData.find((d: { id: string; enCode: string }) => d.enCode === opts.enCode)
|
||||
newId = found?.id
|
||||
} catch {
|
||||
@@ -224,14 +223,15 @@ async function runDiStepMachineCreate(
|
||||
opts: CreateOpts,
|
||||
): Promise<void> {
|
||||
// 1. 拉全 DI 列表 (供 step 2 唯一性预校验, BS-47)
|
||||
// v0.15+ (P0-8) 走 webapi/getDataInterfaceList, 替代 c.get
|
||||
let existingDIs: Array<{ fullName?: string; enCode?: string; id?: string }> = []
|
||||
try {
|
||||
const r = await c.get<{ data?: { list?: Array<any> } }>('/system/DataInterface', {
|
||||
const r = (await getDataInterfaceList({
|
||||
currentPage: 1,
|
||||
pageSize: 1000,
|
||||
category: '30be5ef4e3074dd89385ad6b4540c63d', // BS-17 fix
|
||||
})
|
||||
const list = (r.data as { list?: Array<any> })?.list || []
|
||||
})) as { data?: { list?: Array<any> } } | unknown
|
||||
const list = ((r as { data?: { list?: Array<any> } })?.data?.list) || []
|
||||
existingDIs = list.map((d: any) => ({
|
||||
fullName: d.fullName,
|
||||
enCode: d.enCode,
|
||||
|
||||
@@ -8,7 +8,7 @@ import { Command } from 'commander'
|
||||
import { JnpfClient } from '../../core/client.ts'
|
||||
import { installAiHelpHook } from '../../core/help.ts'
|
||||
import { log, printJson } from '../../core/log.ts'
|
||||
import { initWebapi, loadDataInterface } from '../../webapi/di.ts'
|
||||
import { initWebapi, loadDataInterface, getDataInterfaceList } from '../../webapi/di.ts' // v0.15+ (P0-8): getDataInterfaceList 替代 c.get
|
||||
import { validateDiUpdate, type DiOpts } from './_validate.ts'
|
||||
import { enhanceFromBackend, formatErrorLine } from '../_error_codes.ts'
|
||||
import { dirtyCheck, dirtyCheckFailAndExit } from '../_dirty_check.ts'
|
||||
@@ -127,14 +127,15 @@ async function runDiStepMachine(
|
||||
orig: Record<string, unknown>,
|
||||
): Promise<void> {
|
||||
// 1. 拉全 DI 列表 (供 step 2 唯一性预校验, BS-47)
|
||||
// v0.15+ (P0-8) 走 webapi/getDataInterfaceList, 替代 c.get
|
||||
// 注: 拉列表可能慢, 用 pageSize=1000 单页拉完
|
||||
let existingDIs: Array<{ fullName?: string; enCode?: string; id?: string }> = []
|
||||
try {
|
||||
const r = await c.get<{ data?: { list?: Array<any> } }>('/system/DataInterface', {
|
||||
const r = (await getDataInterfaceList({
|
||||
currentPage: 1,
|
||||
pageSize: 1000,
|
||||
})
|
||||
const list = (r.data as { list?: Array<any> })?.list || []
|
||||
})) as { data?: { list?: Array<any> } } | unknown
|
||||
const list = ((r as { data?: { list?: Array<any> } })?.data?.list) || []
|
||||
existingDIs = list.map((d: any) => ({
|
||||
fullName: d.fullName,
|
||||
enCode: d.enCode,
|
||||
|
||||
@@ -31,3 +31,13 @@ export const loadDataInterface: any = new Proxy({} as any, {
|
||||
return cached[prop]
|
||||
},
|
||||
})
|
||||
|
||||
/** v0.15+ (P0-8, 2026-07-02): 拉 DI 列表 (page list, 镜像 web getDataInterfaceList)
|
||||
* 替代 create.ts:165, create.ts:229, update.ts:133 的 raw c.get('/system/DataInterface', ...)
|
||||
* 统一 webapi 化, 后端路径迁移时自动跟随
|
||||
* @param params { currentPage?, pageSize?, category?, keyword? }
|
||||
* @returns 后端 data 字段 (List<Map>)
|
||||
*/
|
||||
export async function getDataInterfaceList(params: Record<string, unknown> = {}): Promise<unknown> {
|
||||
return loadDataInterface.getDataInterfaceList(params)
|
||||
}
|
||||
Reference in new issue
Block a user