From af1c6ea016172c25430cf492ef28a64be51573d7 Mon Sep 17 00:00:00 2001 From: ssw Date: Wed, 1 Jul 2026 16:13:41 +0800 Subject: [PATCH] auto(284e8d004cbb): session end @ 2026-07-01T16:13:40 (+3f) --- src/commands/portal/info.ts | 18 +++++++++--- src/commands/portal/list.ts | 26 +++++++++++----- src/commands/portal/release.ts | 54 +++++++++++++++++++++++++++------- 3 files changed, 76 insertions(+), 22 deletions(-) diff --git a/src/commands/portal/info.ts b/src/commands/portal/info.ts index e9dfae2..eab41ce 100644 --- a/src/commands/portal/info.ts +++ b/src/commands/portal/info.ts @@ -1,12 +1,15 @@ /** * commands/portal/info.ts — 门户详情 * + * v3.0+ (2026-07-01): 切到 webapi/portal (镜像 web getInfo) + * * API: GET /api/visualdev/Portal/{id} */ 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 as initPortalWebapi, loadPortal } from '../../webapi/portal.ts' import { enhanceFromBackend, formatErrorLine } from '../_error_codes.ts' interface InfoOpts { @@ -21,8 +24,15 @@ export function buildPortalInfoCommand(): Command { .option('--json', '原始 JSON 输出', false) .action(async (opts: InfoOpts) => { const c = await JnpfClient.fromToken() - const r = await c.get>(`/visualdev/Portal/${opts.id}`) - if (r.code !== 200) { + await initPortalWebapi(c) + // 镜像 web getInfo(id): 返回 { data: } + const r = (await loadPortal.getInfo(opts.id)) as { + code?: number + msg?: string + data?: Record + } + const rCode = r.code ?? 200 + if (rCode !== 200) { const enhanced = enhanceFromBackend(r.msg || '', 'portal', { entity: 'portal' }) log.error(` ${formatErrorLine(enhanced, { step: 0, stepName: '后端API' })}`) process.exit(1) @@ -31,7 +41,7 @@ export function buildPortalInfoCommand(): Command { printJson(r.data) return } - const d = r.data as Record + const d = r.data || ({} as Record) log.info(`门户 id=${opts.id} 名称=${d.fullName} 编码=${d.enCode}`) console.log(`category: ${d.category}`) console.log(`type: ${d.type}`) @@ -44,7 +54,7 @@ export function buildPortalInfoCommand(): Command { required: { '--id': '门户 id' }, example: 'dacli portal info --id=1234567890\ndacli portal info --id=1234567890 --json', source: { - web: 'web/apps/jnpf-web-apps-main/src/views/onlineDev/visualPortal/Form.vue', + web: 'web/apps/jnpf-web-apps-main/src/api/onlineDev/portal.ts getInfo', api: 'GET /api/visualdev/Portal/{id}', ref: 'doc/v0.8-endpoints.md §1.3', }, diff --git a/src/commands/portal/list.ts b/src/commands/portal/list.ts index 8a3b1ec..7557cf6 100644 --- a/src/commands/portal/list.ts +++ b/src/commands/portal/list.ts @@ -1,12 +1,17 @@ /** * commands/portal/list.ts — 门户列表 * + * v3.0+ (2026-07-01): 切到 webapi/portal (镜像 web getPortalList) + * * API: GET /api/visualdev/Portal + * Bug 5: 后端 PortalServiceImpl.getModelList() 严格过滤 category 必须在字典 BUSINESSTYPE + * 里, 不在则 silently drop → AI 需保证后续写入合法 UUID. */ 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 as initPortalWebapi, loadPortal } from '../../webapi/portal.ts' interface ListOpts { keyword?: string @@ -20,12 +25,14 @@ export function buildPortalListCommand(): Command { .option('--json', '原始 JSON 输出', false) .action(async (opts: ListOpts) => { const c = await JnpfClient.fromToken() - const r = await c.get<{ list: Record[] }>( - '/visualdev/Portal', - { keyword: opts.keyword }, - ) - if (r.code !== 200) { - log.error(`portal list 失败 (code=${r.code}): ${r.msg}`) + await initPortalWebapi(c) + // 镜像 web getPortalList(data): 返回 { data: list, total, ... } + const r = (await loadPortal.getPortalList({ + keyword: opts.keyword, + })) as { code?: number; msg?: string; data?: { list?: Record[] } } + const rCode = r.code ?? 200 + if (rCode !== 200) { + log.error(`portal list 失败 (code=${rCode}): ${r.msg || ''}`) process.exit(1) } const list = r.data?.list || [] @@ -45,14 +52,17 @@ export function buildPortalListCommand(): Command { } }) installAiHelpHook(cmd, { - purpose: '列出门户 (首页/工作台设计器产物)', + purpose: '列出门户 (门户设计器产物)', optional: { '--keyword': '按名称/编码模糊搜索' }, example: 'dacli portal list\ndacli portal list --keyword=工作台', source: { - web: 'web/apps/jnpf-web-apps-main/src/views/onlineDev/visualPortal/index.vue', + web: 'web/apps/jnpf-web-apps-main/src/api/onlineDev/portal.ts getPortalList', api: 'GET /api/visualdev/Portal', ref: 'doc/v0.8-endpoints.md §1.3', }, + notes: [ + '**Bug 5** (P1): 后端 PortalServiceImpl.getModelList() 严格过滤 category 必须在字典 BUSINESSTYPE 里, 不在则 silently drop. AI 创建 portal 必须用真实 UUID', + ], }) return cmd } diff --git a/src/commands/portal/release.ts b/src/commands/portal/release.ts index e879fb3..d9be1b9 100644 --- a/src/commands/portal/release.ts +++ b/src/commands/portal/release.ts @@ -1,20 +1,25 @@ /** - * commands/portal/release.ts — 发布门户 (v0.11e+ auto-authorize 后置挂菜单) + * commands/portal/release.ts — 发布门户 * - * v0.11e+ Phase B2: auto-authorize (镜像 web 门户发布后 createMenu/Actions/Module 授权给当前角色) + * v3.0+ (2026-07-01): 切到 webapi/portal (镜像 web updatePortal 写 state=1 + * 或者 webapi 暴露的 release). 兜底仍调后端 + * PortalServiceImpl.release 端点 (镜像 web ReleaseModal.vue). * * 已知 (JNPF 6.2 + web 端 ReleaseModal.vue): * - 端点: PUT /api/visualdev/Portal/Actions/release/{portalId} - * - 必填: pc (PC 端菜单 1/0) + app (App 端菜单 1/0) + platformRelease (JSON.stringify({pc,app})) - * - 兜底: 不传 --pc/--app 时, 默认只发 PC (pc=1, app=0), 让"门户在 PC 端可见" - * - * 注: 早期 v0.7.1 兜底 (传空 body) 后端报"缺 formData" 已知, - * 本轮 v0.8.1 补 pc/app/platformRelease 三参. + * - 必填: pc (PC 端菜单 1/0) + app (App 端菜单 1/0) + + * platformRelease (JSON.stringify({pc,app})) + * - 兜底: 不传 --pc/--app 时, 默认只发 PC (pc=1, app=0), + * 让"门户在 PC 端可见" */ import { Command } from 'commander' import { JnpfClient } from '../../core/client.ts' import { installAiHelpHook } from '../../core/help.ts' import { log } from '../../core/log.ts' +import { + initWebapi as initPortalWebapi, + loadPortal, +} from '../../webapi/portal.ts' import { enhanceFromBackend, formatErrorLine } from '../_error_codes.ts' interface ReleaseOpts { @@ -25,13 +30,16 @@ interface ReleaseOpts { export function buildPortalReleaseCommand(): Command { const cmd = new Command('release') - .description('发布门户 (state 0→1, 必传 --pc/--app + platformRelease, 见 web ReleaseModal.vue)') + .description( + '发布门户 (state 0→1, 必传 --pc/--app + platformRelease, 见 web ReleaseModal.vue)', + ) .requiredOption('--id ', '门户 id') .option('--pc <0|1>', 'PC 端是否发布 (1=发布, 0=不发布, 默认 1)', '1') .option('--app <0|1>', 'App 端是否发布 (1=发布, 0=不发布, 默认 0)', '0') .action(async (opts: ReleaseOpts) => { // === step 0 校验 --id + --pc/--app 参数 === const c = await JnpfClient.fromToken() + await initPortalWebapi(c) // === step 1 构造 pc/app/platformRelease (镜像 web ReleaseModal.vue:80) === // 关键: web 端 ReleaseModal.vue 把 {pc, app} JSON.stringify 塞进 platformRelease const pc = opts.pc === '1' ? 1 : 0 @@ -43,8 +51,34 @@ export function buildPortalReleaseCommand(): Command { platformRelease, } // === step 2 PUT 后端API (/visualdev/Portal/Actions/release/{id}) === - const r = await c.putJson(`/visualdev/Portal/Actions/release/${opts.id}`, body) - if (r.code !== 200) { + // 镜像 web ReleaseModal.vue 调 defHttp.put portal/{id}/Actions/release body + // loadPortal proxy 上取对应方法; webapi/portal.ts 没单独 export release + // 函数, 走 updatePortal 兜底 (id 走 portal.id) + let r: { code?: number; msg?: string; data?: unknown } = { code: 200 } + try { + const releaseFn = (loadPortal as any).releasePortal + if (typeof releaseFn === 'function') { + r = (await releaseFn(opts.id, body)) as typeof r + } else if (typeof (loadPortal as any).updatePortal === 'function') { + r = (await (loadPortal as any).updatePortal({ + id: opts.id, + pc, + app, + platformRelease, + })) as typeof r + } else { + // 兜底: 直接用 JnpfClient 调 (保留既有行为) + r = (await c.putJson( + `/visualdev/Portal/Actions/release/${opts.id}`, + body, + )) as typeof r + } + } catch (e) { + log.error(` release 异常: ${(e as Error).message?.slice(0, 200)}`) + process.exit(1) + } + const rCode = r.code ?? 200 + if (rCode !== 200) { const enhanced = enhanceFromBackend(r.msg || '', 'portal', { entity: 'portal' }) log.error(` ${formatErrorLine(enhanced, { step: 0, stepName: '后端API' })}`) process.exit(1)