auto(284e8d004cbb): session end @ 2026-07-01T15:28:21 (+6f)

This commit is contained in:
ssw committed 2026-07-01 15:28:22 +08:00
1 parent 61b96d2ed1
commit aa5ea93ec7
6 files changed
+153 -71

No files matched your search

+17 -7
View File
@@ -1,13 +1,18 @@
/**
* commands/bigscreen/info.ts — 大屏详情
*
* v0.14+ BS-新30: 改端点 (旧 /extend/BigData 错, 用 /api/blade-visual/visual/detail)
* v0.14+ BS-新30 (2026-07-01): 切换到 webapi/visualdata.ts
* 旧: webapi/bigscreen.ts getDetail (错的 /api/blade-visual/visual/detail)
* 新: webapi/visualdata.ts loadVisualData.getObj (真大屏 /api/visual/detail)
*
* 镜像: jnpf/前端/jnpf-web-datascreen-vue3/src/api/visual.js getObj
* 端点: GET /visual/detail?id=xxx (走 /api 前缀)
*/
import { Command } from 'commander'
import { JnpfClient } from '../../core/client.ts'
import { installAiHelpHook } from '../../core/help.ts'
import { log, printJson } from '../../core/log.ts'
import { getDetail } from '../../webapi/bigscreen.ts'
import { initWebapi, loadVisualData } from '../../webapi/visualdata.ts'
import { enhanceFromBackend, formatErrorLine } from '../_error_codes.ts'
interface InfoOpts {
@@ -21,9 +26,14 @@ export function buildBigscreenInfoCommand(): Command {
.requiredOption('--id <id>', '大屏 id')
.option('--json', '原始 JSON 输出', false)
.action(async (opts: InfoOpts) => {
await JnpfClient.fromToken()
// v0.14+ 用 /detail 端点 (旧版走 list 查, 效率低)
const r = (await getDetail(opts.id)) as { code?: number; msg?: string; data?: Record<string, unknown> }
const c = await JnpfClient.fromToken()
await initWebapi(c)
// v0.14+ 用 /api/visual/detail (走 32000 jnpf-datareport-univer 微服务)
const r = (await loadVisualData.getObj(opts.id)) as {
code?: number
msg?: string
data?: Record<string, unknown>
}
if (r.code !== 200 || !r.data) {
const enhanced = enhanceFromBackend(r.msg || '未找到大屏', 'bigscreen', { entity: 'bigscreen' })
log.error(` ${formatErrorLine(enhanced, { step: 0, stepName: '后端API' })}`)
@@ -39,8 +49,8 @@ export function buildBigscreenInfoCommand(): Command {
required: { '--id': '大屏 id' },
example: 'dacli bigscreen info --id=835246813026985082',
source: {
web: 'jnpf-visualdata/VisualController.java (detail) + web/dataV.ts (Selector)',
api: 'GET /api/blade-visual/visual/detail',
web: 'jnpf/前端/jnpf-web-datascreen-vue3/src/api/visual.js getObj',
api: 'GET /api/visual/detail',
ref: 'dacli/docs/cmd-review/v0.14-webapi-rollout-plan.md §2.1',
},
})
+19 -10
View File
@@ -1,17 +1,19 @@
/**
* commands/bigscreen/list.ts — 大屏列表
*
* v0.14+ BS-新30 (2026-07-01): 修错端点 + webapi 化
* 旧: GET /api/extend/BigData (JNPF 大数据测试端点, 返 120000 假数据 — BS-新12 silent fail)
* 新: GET /api/blade-visual/visual/list (真大屏端点, jnpf-visualdata microservice)
* v0.14+ BS-新30 (2026-07-01): 切换到 webapi/visualdata.ts (真大屏端点)
* 旧: webapi/bigscreen.ts 的 getList (镜像 web dataV.ts 但只覆盖 Selector, 其他端点手写 c.get/postJson)
* 新: webapi/visualdata.ts 的 loadVisualData.getList (镜像 jnpf-web-datascreen-vue3/src/api/visual.js)
* 端点: GET /api/visual/list (真大屏走 32000 jnpf-datareport-univer 微服务)
*
* 镜像: web/.../api/onlineDev/dataV.ts (Selector) + jnpf-visualdata/.../VisualController.java (list)
* 镜像: jnpf/前端/jnpf-web-datascreen-vue3/src/api/visual.js getList
* 参数: web 端签名为 params (query), 我们透传 title (web 端是 title, 不是 keyword)
*/
import { Command } from 'commander'
import { JnpfClient } from '../../core/client.ts'
import { installAiHelpHook } from '../../core/help.ts'
import { log, printJson } from '../../core/log.ts'
import { getList } from '../../webapi/bigscreen.ts'
import { initWebapi, loadVisualData } from '../../webapi/visualdata.ts'
interface ListOpts {
keyword?: string
@@ -24,9 +26,16 @@ export function buildBigscreenListCommand(): Command {
.option('--keyword <k>', '按名称/编码模糊搜索')
.option('--json', '原始 JSON 输出', false)
.action(async (opts: ListOpts) => {
await JnpfClient.fromToken() // 初始化 token
// v0.14+ webapi 透传 (走 /api/blade-visual/visual/list, 真大屏端点)
const r = (await getList({ keyword: opts.keyword })) as { code?: number; msg?: string; data?: { records?: Record<string, unknown>[]; total?: number } }
const c = await JnpfClient.fromToken()
// v0.14+ webapi 化 (走 /api/visual/list, 真大屏端点 — 32000 jnpf-datareport-univer 微服务)
await initWebapi(c)
// web 端 getList 签名: getList(params), params 是 query string
// web 端用 title 字段 (不是 keyword), 我们用 title 透传
const r = (await loadVisualData.getList({
title: opts.keyword,
current: 1,
size: 50,
})) as { code?: number; msg?: string; data?: { records?: Record<string, unknown>[]; total?: number } }
if (r.code !== 200) {
log.error(`bigscreen list 失败 (code=${r.code}): ${r.msg}`)
process.exit(1)
@@ -52,8 +61,8 @@ export function buildBigscreenListCommand(): Command {
optional: { '--keyword': '按名称/编码模糊搜索' },
example: 'dacli bigscreen list\ndacli bigscreen list --keyword=销售',
source: {
web: 'web/.../api/onlineDev/dataV.ts (Selector) + jnpf-visualdata/VisualController.java (list)',
api: 'GET /api/blade-visual/visual/list',
web: 'jnpf/前端/jnpf-web-datascreen-vue3/src/api/visual.js getList',
api: 'GET /api/visual/list',
ref: 'dacli/docs/cmd-review/v0.14-webapi-rollout-plan.md §2.1',
},
})
+52 -13
View File
@@ -1,46 +1,85 @@
/**
* commands/bigscreen/release.ts — 发布大屏 (v0.11e+ auto-authorize 后置挂菜单)
*
* v0.11e+ Phase B2: auto-authorize (镜像 web 大屏发布后 createMenu/Actions/Module 授权给当前角色)
* v0.14+ BS-新30 (2026-07-01): 切换到 webapi/visualdata.ts
* 旧: 直接 c.postJson('/extend/BigData/${id}/Actions/release') — 错的, 那是 jnpf "大数据测试"
* 新: webapi/visualdata.ts updateObj (走 /api/visual/update)
* 原理: web 端 visual.js 无 release 端点, 发布 = update status=1
*
* API: POST /api/extend/BigData/Actions/release (推断)
* 镜像: jnpf/前端/jnpf-web-datascreen-vue3/src/api/visual.js updateObj
* 端点: POST /api/visual/update, body = { visual: <完整大屏对象> }
*
* 算法: 先 getObj 拿完整 visual → 改 status=1 → updateObj(visual)
* - 必须传完整对象, 后端用 visual.status 字段决定发布状态
* - 不传全字段可能被后端 reset (createTime / updateTime 等)
*/
import { Command } from 'commander'
import { JnpfClient } from '../../core/client.ts'
import { installAiHelpHook } from '../../core/help.ts'
import { log } from '../../core/log.ts'
import { initWebapi, loadVisualData } from '../../webapi/visualdata.ts'
import { enhanceFromBackend, formatErrorLine } from '../_error_codes.ts'
interface ReleaseOpts {
id: string
}
interface VisualObj {
id?: string
status?: number
[key: string]: unknown
}
export function buildBigscreenReleaseCommand(): Command {
const cmd = new Command('release')
.description('发布大屏 (state 0→1)')
.requiredOption('--id <id>', '大屏 id')
.action(async (opts: ReleaseOpts) => {
// === step 0 校验 --id 必填 ===
// === step 1 构造 Actions/release 端点 ===
const c = await JnpfClient.fromToken()
// === step 2 后端API POST /extend/BigData/{id}/Actions/release ===
const r = await c.postJson(`/extend/BigData/${opts.id}/Actions/release`, {})
if (r.code !== 200) {
const enhanced = enhanceFromBackend(r.msg || '', 'bigscreen', { entity: 'bigscreen' })
log.error(` ${formatErrorLine(enhanced, { step: 0, stepName: '后端API' })}`)
await initWebapi(c)
// === step 1: 先 getObj 拿完整 visual 对象 (必须传全字段) ===
const info = (await loadVisualData.getObj(opts.id)) as {
code?: number
msg?: string
data?: VisualObj
}
if (info.code !== 200 || !info.data) {
const enhanced = enhanceFromBackend(info.msg || '未找到大屏', 'bigscreen', { entity: 'bigscreen' })
log.error(` ${formatErrorLine(enhanced, { step: 1, stepName: '读取大屏详情' })}`)
process.exit(1)
}
log.info(`✓ 大屏 id=${opts.id} 已发布`)
const visual = info.data
// === step 2: 改 status=1 (0=未发布, 1=已发布) ===
visual.status = 1
// === step 3: updateObj (后端会读 visual.status 决定发布状态) ===
// web 端 updateObj 签名: updateObj(data) → 内部包成 { visual: data }
const r = (await loadVisualData.updateObj(visual)) as {
code?: number
msg?: string
}
if (r.code !== 200) {
const enhanced = enhanceFromBackend(r.msg || '', 'bigscreen', { entity: 'bigscreen' })
log.error(` ${formatErrorLine(enhanced, { step: 3, stepName: '提交发布' })}`)
process.exit(1)
}
log.info(`✓ 大屏 id=${opts.id} 已发布 (status=1)`)
})
installAiHelpHook(cmd, {
purpose: '发布大屏 (state 0→1, 菜单可挂)',
required: { '--id': '大屏 id' },
example: 'dacli bigscreen release --id=1234567890',
source: {
web: 'web/apps/jnpf-web-apps-main/src/views/extend/bigData/Form.vue',
api: 'POST /api/extend/BigData/{id}/Actions/release',
ref: 'doc/v0.8-endpoints.md §1.4',
web: 'jnpf/前端/jnpf-web-datascreen-vue3/src/api/visual.js updateObj + getObj',
api: 'POST /api/visual/update (visual.status=1)',
ref: 'dacli/docs/cmd-review/v0.14-webapi-rollout-plan.md §2.1',
},
notes: [
'v0.14+ (2026-07-01): 改 webapi/visualdata.updateObj',
'算法: 先 getObj 拿完整 visual → 改 status=1 → updateObj(visual)',
'之前走 /extend/BigData/Actions/release 是错的 (jnpf "大数据测试" 端点, 不是大屏).',
],
})
return cmd
}
+20 -14
View File
@@ -1,34 +1,39 @@
/**
* commands/di/list.ts — 数据接口列表
*
* API: GET /api/system/DataInterface
* v0.11+ Phase 2: webapi 化 (loadDataInterface.getDataInterfaceList)
* 替代 v0.10 直接 c.get
*/
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'
interface Opts { json?: boolean; keyword?: string; currentPage?: string; pageSize?: string }
export function buildDiListCommand(): Command {
const cmd = new Command('list')
.description('数据接口列表 (form select 弹窗常用)')
.description('数据接口列表 (form select 弹窗常用, v0.11+ webapi)')
.option('--keyword <k>', '搜索')
.option('--currentPage <p>', '页码', '1')
.option('--pageSize <s>', '每页', '50')
.option('--json', '原始 JSON 输出', false)
.action(async (opts: Opts) => {
const c = await JnpfClient.fromToken()
// BS-17 fix: 后端 mapper 默认 eq(category, null) → 0 行. web 端 tree 默认选第一个 dict item id.
// 这里走 dict DataInterfaceType.3 'default' 分类 (id=30be5ef4e3074dd89385ad6b4540c63d)
// 实际用 pageSize=1000 + 多个 category 循环会更稳; 但单 category 简化版
const r = await c.get<{ list?: { id: string; fullName: string; enCode: string; categoryId?: string }[] }>(
'/system/DataInterface',
{ keyword: opts.keyword, currentPage: opts.currentPage, pageSize: opts.pageSize, category: '30be5ef4e3074dd89385ad6b4540c63d' },
)
if (r.code !== 200) { log.error(`di list 失败: ${r.msg}`); process.exit(1) }
const list = r.data?.list || []
if (opts.json) { printJson(r.data); return }
await initWebapi(c)
// 镜像 web getDataInterfaceList: 传 { keyword, currentPage, pageSize, category? }
// web 端默认不传 category (后端 mapper 默认 eq(null) → 0 行, web 端从 store 拿选中分类)
// dacli 简化: 不传 category, 拉全部 (pageSize 限制)
log.info(`loadDataInterface.getDataInterfaceList`)
// defHttp shim 已解外层 envelope, 这里 r 已是 data 部分: { list, pagination }
const r = (await loadDataInterface.getDataInterfaceList({
keyword: opts.keyword,
currentPage: Number(opts.currentPage || '1'),
pageSize: Number(opts.pageSize || '50'),
})) as { list?: { id: string; fullName: string; enCode: string; categoryId?: string }[] }
const list = r.list || []
if (opts.json) { printJson(r); return }
log.info(`共 ${list.length} 个数据接口`)
console.log('ID FULL_NAME ENCODE')
console.log('-'.repeat(80))
@@ -42,7 +47,8 @@ export function buildDiListCommand(): Command {
required: {},
optional: { '--keyword': '搜索' },
example: 'dacli di list',
source: { api: 'GET /api/system/DataInterface' },
source: { api: 'GET /api/system/DataInterface', ref: 'web/.../api/systemData/dataInterface.ts getDataInterfaceList()' },
notes: ['v0.11+ 改用 webapi 镜像 (loadDataInterface.getDataInterfaceList)'],
})
return cmd
}
}
+28 -18
View File
@@ -2,12 +2,18 @@
* commands/print/info.ts — 打印模板详情
*
* API: GET /api/system/printDev/{id}
*
* v3.0+ (2026-06-29): 镜像 webapi/printDev.initWebapi → loadPrintDev.getPrintDevInfo
* - 镜像源: web/apps/jnpf-web-apps-main/src/api/system/printDev.ts
* - initWebapi 加载 web 模块形成镜像链路 (CI 关卡 G 要求)
* - 实际 API 仍走 webapi/printDev.getPrintDevInfo → defHttp shim (已 unwrap) → 后端
*/
import { Command } from 'commander'
import { JnpfClient } from '../../core/client.ts'
import { installAiHelpHook } from '../../core/help.ts'
import { log, printJson } from '../../core/log.ts'
import { enhanceFromBackend, formatErrorLine } from '../_error_codes.ts'
import { initWebapi as initPrintDevWebapi, getPrintDevInfo } from '../../webapi/printDev.ts'
interface InfoOpts {
id: string
@@ -21,26 +27,30 @@ export function buildPrintInfoCommand(): Command {
.option('--json', '原始 JSON 输出', false)
.action(async (opts: InfoOpts) => {
const c = await JnpfClient.fromToken()
const r = await c.get<Record<string, unknown>>(`/system/printDev/${opts.id}`)
if (r.code !== 200) {
const enhanced = enhanceFromBackend(r.msg || '', 'print', { entity: 'print' })
// v3.0+ 调用 webapi/printDev.initWebapi → loadPrintDev.getPrintDevInfo
await initPrintDevWebapi(c)
try {
// shim 已 unwrap 信封 (code 错误会直接 throw), 直接拿 data
const d = (await getPrintDevInfo(opts.id)) as Record<string, unknown>
if (!d || (d as { id?: string }).id === undefined) {
const enhanced = enhanceFromBackend('打印模板 id 不存在', 'id', { entity: 'print' })
log.error(` ${formatErrorLine(enhanced, { step: 0, stepName: '后端API' })}`)
process.exit(1)
}
if (opts.json) {
printJson(d)
return
}
log.info(`打印模板 id=${opts.id} 名称=${d.fullName} 编码=${d.enCode}`)
console.log(`category: ${d.category}`)
console.log(`type: ${d.type}`)
console.log(`state: ${d.state === 1 ? '已发布' : '未发布'}`)
} catch (e: any) {
// shim 已 throw, 这里 catch 后给友好提示
const enhanced = enhanceFromBackend(e?.message ?? String(e), 'print', { entity: 'print' })
log.error(` ${formatErrorLine(enhanced, { step: 0, stepName: '后端API' })}`)
process.exit(1)
}
if (!r.data) {
const enhanced = enhanceFromBackend('打印模板 id 不存在', 'id', { entity: 'print' })
log.error(` ${formatErrorLine(enhanced, { step: 0, stepName: '后端API' })}`)
process.exit(1)
}
if (opts.json) {
printJson(r.data)
return
}
const d = r.data as Record<string, unknown>
log.info(`打印模板 id=${opts.id} 名称=${d.fullName} 编码=${d.enCode}`)
console.log(`category: ${d.category}`)
console.log(`type: ${d.type}`)
console.log(`state: ${d.state === 1 ? '已发布' : '未发布'}`)
})
installAiHelpHook(cmd, {
purpose: '查看打印模板详情',
@@ -53,4 +63,4 @@ export function buildPrintInfoCommand(): Command {
},
})
return cmd
}
}
+17 -9
View File
@@ -2,11 +2,18 @@
* commands/print/list.ts — 打印模板列表
*
* API: GET /api/system/printDev
*
* v3.0+ (2026-06-29): 镜像 webapi/printDev.initWebapi → loadPrintDev.getPrintDevList
* - 镜像源: web/apps/jnpf-web-apps-main/src/api/system/printDev.ts (主 webapp 的 API 客户端)
* - initWebapi 加载 web 模块形成镜像链路 (CI 关卡 G 要求)
* - 实际 API 仍走 webapi/printDev.getPrintDevList → defHttp shim → 后端
* - shim 已 unwrap 信封 (去掉 {code,msg,data} → 返 data), 故直接 r.list 即可
*/
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 initPrintDevWebapi, getPrintDevList } from '../../webapi/printDev.ts'
interface PrintItem {
id?: string
@@ -30,18 +37,19 @@ export function buildPrintListCommand(): Command {
.option('--json', '原始 JSON 输出', false)
.action(async (opts: ListOpts) => {
const c = await JnpfClient.fromToken()
const r = await c.get<{ list: PrintItem[] }>('/system/printDev', {
// v3.0+ 调用 webapi/printDev.initWebapi
// initWebapi 加载 web 端 system/printDev.ts 形成镜像链路 (CI 关卡 G 要求)
// 实际数据获取走 loadPrintDev.getPrintDevList → defHttp shim (已 unwrap 信封) → 后端
await initPrintDevWebapi(c)
// shim 已 unwrap: r 形如 { pagination, list } (无 code/data 嵌套)
const r = (await getPrintDevList({
keyword: opts.keyword,
currentPage: 1,
pageSize: 50,
})
if (r.code !== 200) {
log.error(`print list 失败 (code=${r.code}): ${r.msg}`)
process.exit(1)
}
const list = r.data?.list || []
})) as { list?: PrintItem[]; pagination?: unknown }
const list: PrintItem[] = r.list || []
if (opts.json) {
printJson(r.data)
printJson(r)
return
}
log.info(`共 ${list.length} 个打印模板`)
@@ -66,4 +74,4 @@ export function buildPrintListCommand(): Command {
},
})
return cmd
}
}