auto(284e8d004cbb): session end @ 2026-06-29T16:39:21 (+2f)
This commit is contained in:
1 parent
c9285962dd
commit
bb2be67bf0
2 files changed
+44
-16
No files matched your search
@@ -13,7 +13,7 @@ interface Opts { tag?: string; method?: string; keyword?: string; json?: boolean
|
||||
|
||||
export function buildApisListCommand(): Command {
|
||||
const cmd = new Command('list')
|
||||
.description('列 JNPF 平台所有 API (从 /v3/api-docs 拉取, 12h in-memory 缓存)')
|
||||
.description('列 JNPF 平台所有 API (从 /v3/api-docs 拉取, 12h SQLite 缓存, --tag OR 匹配)')
|
||||
.option('--tag <t>', '按 tag 过滤 (e.g. visualdev / system / workflow)')
|
||||
.option('--method <m>', '按 HTTP method 过滤 (GET/POST/...)')
|
||||
.option('--keyword <k>', '按 path 或 summary 搜索')
|
||||
@@ -25,7 +25,10 @@ export function buildApisListCommand(): Command {
|
||||
for (const [path, methods] of Object.entries(doc.paths || {})) {
|
||||
for (const [method, op] of Object.entries(methods)) {
|
||||
if (opts.method && method.toUpperCase() !== opts.method.toUpperCase()) continue
|
||||
if (opts.tag && !(op.tags || []).includes(opts.tag)) continue
|
||||
// v3.0+ (2026-06-29 regression audit): 对齐 Java 版 ApiService.java:147 OR 匹配
|
||||
// 旧实现: 纯 AND (仅匹配 op.tags), 漏掉 path 含 tag 但 tags 不含的接口
|
||||
// 新实现: OR (op.tags.includes OR path.includes), 与 Java 版行为一致
|
||||
if (opts.tag && !(op.tags || []).includes(opts.tag) && !path.includes(opts.tag)) continue
|
||||
if (opts.keyword && !`${path} ${op.summary || ''}`.toLowerCase().includes(opts.keyword.toLowerCase())) continue
|
||||
rows.push({ method: method.toUpperCase(), path, summary: op.summary || '', tags: op.tags || [] })
|
||||
}
|
||||
|
||||
@@ -1,23 +1,28 @@
|
||||
/**
|
||||
* commands/print/create.ts — 新建打印模板 (v0.11e+ Phase D1 wire up)
|
||||
* commands/print/create.ts — 新建打印模板 (v0.11e+ Phase D1 wire up, v3.0+ 重构)
|
||||
*
|
||||
* 决策 6: 打印模板 webType=1-2 (printDev), 不需要物理表, 绑 form 数据
|
||||
*
|
||||
* API: POST /api/system/printDev
|
||||
*
|
||||
* 镜像 web onlineDev/printDev/Form.vue + 后端 PrintDevController
|
||||
* - fullName 必填 (PRI001 镜像)
|
||||
* - enCode 必填 + formValidate 正则
|
||||
* 镜像 web onlineDev/printDev/Form.vue schemas (L29-92) + handleSubmit (L96-138)
|
||||
* - fullName 必填 (maxlength 100, **注意是 100 不是 50**, web printDev 特殊)
|
||||
* - enCode formValidate('enCode') + maxlength 50 (BS-56)
|
||||
* - category 必填 (1=系统打印 2=表单打印)
|
||||
* - formId 当 category=2 时必填
|
||||
* - commonUse (Switch, 默认 0) → 条件校验: =1 时 icon 必填
|
||||
* - visibleType (1=公开 / 2=权限设置) → 仅 commonUse=1 时显示
|
||||
* - formId 当 category=2 时必填 (v3: web 隐含约束, 易漏)
|
||||
*
|
||||
* v0.11e+ Phase D1: P3 命令 step machine 集成
|
||||
* v3.0+ (2026-06-29) 重要重构:
|
||||
* - 改用独立 _validate.ts (不再复用 report/_validate.ts)
|
||||
* - 回归审计发现 print 有 8 字段, report 只有 2-4 字段, 借用导致校验不全
|
||||
* - 详见 dacli/docs/cmd-review/regression-2026-06-29.md
|
||||
*/
|
||||
import { Command } from 'commander'
|
||||
import { JnpfClient } from '../../core/client.ts'
|
||||
import { installAiHelpHook } from '../../core/help.ts'
|
||||
import { log, printJson } from '../../core/log.ts'
|
||||
import { validateBasicInfo } from '../report/_validate.ts'
|
||||
import { validatePrintCreate } from './_validate.ts'
|
||||
import { enhanceFromBackend, formatErrorLine } from '../_error_codes.ts'
|
||||
|
||||
interface CreateOpts {
|
||||
@@ -25,26 +30,42 @@ interface CreateOpts {
|
||||
enCode: string
|
||||
category: string
|
||||
formId?: string
|
||||
commonUse?: string
|
||||
visibleType?: string
|
||||
icon?: string
|
||||
description?: string
|
||||
sortCode?: string
|
||||
json?: boolean
|
||||
}
|
||||
|
||||
export function buildPrintCreateCommand(): Command {
|
||||
const cmd = new Command('create')
|
||||
.description('新建打印模板 (绑 form 数据, 不需要物理表)')
|
||||
.requiredOption('--fullName <name>', '打印模板名称')
|
||||
.requiredOption('--enCode <code>', '打印模板编码')
|
||||
.requiredOption('--fullName <name>', '打印模板名称 (maxlength 100, web printDev 特殊)')
|
||||
.requiredOption('--enCode <code>', '打印模板编码 (formValidate 正则, BS-56)')
|
||||
.requiredOption('--category <cat>', '分类: 1=系统打印 2=表单打印')
|
||||
.option('--formId <id>', '绑定的 form id (form 打印时必填)')
|
||||
.option('--formId <id>', '绑定的 form id (category=2 时必填, v3 新增)')
|
||||
.option('--commonUse <0|1>', '常用标记 (Switch, 默认 0, =1 时 icon 必填)', '0')
|
||||
.option('--icon <name>', '图标 (commonUse=1 时必填, v3 条件校验)')
|
||||
.option('--visibleType <1|2>', '发布范围 (1=公开 2=权限设置, 仅 commonUse=1 时校验)', '1')
|
||||
.option('--description <desc>', '说明 (Textarea)')
|
||||
.option('--sortCode <n>', '排序码 (0-999999)', '0')
|
||||
.option('--json', '原始 JSON 输出', false)
|
||||
.action(async (opts: CreateOpts) => {
|
||||
const c = await JnpfClient.fromToken()
|
||||
|
||||
// v0.11e+ Phase D1: step machine 校验 (复用 report/_validate.ts, 基础信息)
|
||||
// step 0 基础信息 (fullName/enCode/category)
|
||||
const validation = validateBasicInfo({
|
||||
// v3.0+ step machine 校验 (3 step: 基础信息 + 数值范围 + 条件校验)
|
||||
// 镜像 web printDev/Form.vue:29-92 schemas + ifShow 规则 (L65-77)
|
||||
const validation = validatePrintCreate({
|
||||
fullName: opts.fullName,
|
||||
enCode: opts.enCode,
|
||||
category: opts.category,
|
||||
formId: opts.formId,
|
||||
commonUse: opts.commonUse,
|
||||
visibleType: opts.visibleType,
|
||||
icon: opts.icon,
|
||||
description: opts.description,
|
||||
sortCode: opts.sortCode,
|
||||
})
|
||||
if (!validation.ok) {
|
||||
for (const s of validation.steps) {
|
||||
@@ -62,9 +83,13 @@ export function buildPrintCreateCommand(): Command {
|
||||
category: opts.category,
|
||||
type: opts.category === '1' ? 1 : 2,
|
||||
enabledMark: 1,
|
||||
sortCode: 0,
|
||||
sortCode: Number(opts.sortCode ?? 0),
|
||||
}
|
||||
if (opts.formId) body.moduleId = opts.formId
|
||||
if (opts.commonUse !== undefined) body.commonUse = Number(opts.commonUse)
|
||||
if (opts.visibleType !== undefined) body.visibleType = Number(opts.visibleType)
|
||||
if (opts.icon) body.icon = opts.icon
|
||||
if (opts.description) body.description = opts.description
|
||||
const r = await c.postJson<{ id?: string }>('/system/printDev', body)
|
||||
if (r.code !== 200) {
|
||||
const enhanced = enhanceFromBackend(r.msg || '', 'print', { entity: 'print' })
|
||||
|
||||
Reference in new issue
Block a user