P2-1 修复: report list 兼容 --category/--type + deprecation warn (2026-07-02)

FINDING-R6: v0.14 webapi 切换静默破坏
  - 旧版 list 有 --category/--type (走 /api/ReportManage 端点支持 server 端过滤)
  - v0.14 切 webapi 后只 --keyword 模糊搜索, 旧脚本/AK 文档失效
  - 老用户跑 'dacli report list --category=大赛报表' → 'unknown option --category' 退出 1

修复:
- 保留 --category/--type 选项, log.warn 标 deprecation
- 转发到 --keyword 客户端过滤 (后端 /api/Report 无 server 端 category/type 过滤)
- v0.16+ 将彻底移除 (本次是兼容期)

审计: dacli/docs/cmd-review/v0.14-rollout-audit-2026-07-02.md §2.1 R6
This commit is contained in:
ssw committed 2026-07-02 12:35:33 +08:00
1 parent 618c905053
commit f0eb417a62
1 file changed
+28 -1
+28 -1
View File
@@ -35,6 +35,9 @@ interface ListOpts {
json?: boolean
currentPage?: string
pageSize?: string
// v0.15+ (P2-1): 兼容旧版 --category/--type, 转发到 keyword + deprecation warn
category?: string
type?: string
}
export function buildReportListCommand(): Command {
@@ -43,14 +46,32 @@ export function buildReportListCommand(): Command {
.option('--keyword <k>', '按名称模糊搜索')
.option('--currentPage <p>', '页码', '1')
.option('--pageSize <s>', '每页', '50')
// v0.15+ (P2-1): 兼容旧版选项, 转发到 keyword 模糊搜索 + deprecation warn
// 旧版 (cmd-review/report.md § 1) 有 --category --type, v0.14 切 webapi 静默丢失
.option('--category <c>', '[已弃用] 按分类过滤, 改用 --keyword=<分类名/enCode>')
.option('--type <t>', '[已弃用] 按报表类型过滤, 改用 --keyword=<类型>')
.option('--json', '原始 JSON 输出', false)
.action(async (opts: ListOpts) => {
const c = await JnpfClient.fromToken()
// v0.15+ (P2-1): 兼容 --category/--type 转发到 keyword + 提示
// 旧版用 /api/ReportManage 端点支持 category/type 过滤, 现 webapi 走 /api/Report
// 端点只有 keyword 模糊搜索, 没法 server 端 category/type 过滤
let finalKeyword = opts.keyword || ''
if (opts.category) {
log.warn('P2-1: --category 已弃用, 改用 --keyword=<分类名/enCode> 客户端过滤')
finalKeyword = finalKeyword ? `${finalKeyword} ${opts.category}` : opts.category
}
if (opts.type) {
log.warn('P2-1: --type 已弃用, 改用 --keyword=<类型> 客户端过滤')
finalKeyword = finalKeyword ? `${finalKeyword} ${opts.type}` : opts.type
}
// v0.14+ webapi 化: 调用 web 端原版 getReportList (走 reportHttp, 端点 /api/Report)
await initReportWebapi(c)
// web 端 getReportList(params) — params 是 query string, 含 keyword / currentPage / pageSize
const r = (await loadReport.getReportList({
keyword: opts.keyword,
keyword: finalKeyword,
currentPage: Number(opts.currentPage || '1'),
pageSize: Number(opts.pageSize || '50'),
})) as {
@@ -86,6 +107,9 @@ export function buildReportListCommand(): Command {
'--keyword': '按名称模糊搜索',
'--currentPage': '页码 (默认 1)',
'--pageSize': '每页 (默认 50)',
// v0.15+ (P2-1): 标 deprecation
'--category': '[已弃用, 兼容保留] 按分类过滤',
'--type': '[已弃用, 兼容保留] 按类型过滤',
},
example: 'dacli report list\ndacli report list --keyword=月报',
source: {
@@ -97,6 +121,9 @@ export function buildReportListCommand(): Command {
'v0.14+: 改用 webapi 镜像 (loadReport.getReportList), 替代旧版 c.get("/extend/ReportManage")',
'**报表数据来源**: 报表微服务端口 32000 (jnpf-datareport-univer), 通过 nginx /api/Report/ 路径代理',
'**nCOPE BACKEND-7**: 当前 dacli 测试环境 nginx /api/Report 重定向到 /api/Report/ → 404 (Spring 不识别带斜杠根), 需在 _defhttp_shim.ts 改 reportHttp 走独立 32000 client (后续 PR)',
// v0.15+ (P2-1): 兼容说明
'**v0.15+ (P2-1)**: 旧版 --category/--type 兼容保留, 转发到 --keyword 模糊搜索 + deprecation warn',
' 老用户脚本继续能用, 不报错, v0.16+ 将彻底移除 (breaking change)',
],
})
return cmd