feat(v0.11+): schedule update/delete + msg notice/template CRUD (6 个 P0 NEW-CMD)

Phase 1 审计 (cmd-review/schedule.md + msg.md) 标记 P0 必补:

schedule 子命令 (P0 闭环):
- schedule update (改 cron/executeContent/enabledMark, 避免 delete+create)
- schedule delete (硬删, --yes 确认)
- 累计 schedule 7 子命令 (从 5 → 7)

msg 子命令 (P0 CRUD 闭环):
- msg noticeUpdate (改公告)
- msg noticeDelete (删公告)
- msg templateUpdate (改模板)
- msg templateDelete (删模板)
- 累计 msg 9 子命令 (从 5 → 9)

注: schedule enabledMark 替代 pause/resume (JNPF 无独立 API)
注: storage CRUD 暂不做, 因 storage 配置走 yml 无 API (cmd-review/storage.md 已说明)

Co-Authored-By: Claude <[email protected]>
This commit is contained in:
sswandClaude committed 2026-06-25 15:22:51 +08:00
1 parent 5ec47e35f2
commit 6be66cbb76
8 files changed
+350 -3

No files matched your search

+14 -2
View File
@@ -5,26 +5,38 @@
*
* 决策 8: 通知通道 site/email/sms/webhook/dingTalk/weCom
*
* 子命令:
* v0.11+ Phase 2: 9 子命令 (闭环 CRUD)
* noticelist 通知列表
* noticecreate 新建通知
* noticeupdate 改通知 (P0 v0.11+)
* noticedelete 删通知 (P0 v0.11+)
* noticesend 发送通知
* templatelist 模板列表
* templatecreate 新建模板
* templateupdate 改模板 (P0 v0.11+)
* templatedelete 删模板 (P0 v0.11+)
*/
import { Command } from 'commander'
import { buildMsgNoticeListCommand } from './noticelist.ts'
import { buildMsgNoticeCreateCommand } from './noticecreate.ts'
import { buildMsgNoticeUpdateCommand } from './noticeupdate.ts'
import { buildMsgNoticeDeleteCommand } from './noticedelete.ts'
import { buildMsgNoticeSendCommand } from './noticesend.ts'
import { buildMsgTemplateListCommand } from './templatelist.ts'
import { buildMsgTemplateCreateCommand } from './templatecreate.ts'
import { buildMsgTemplateUpdateCommand } from './templateupdate.ts'
import { buildMsgTemplateDeleteCommand } from './templatedelete.ts'
export function buildMsgCommand(): Command {
const cmd = new Command('msg').description('消息中心 (通知 + 模板, msgCenter)')
const cmd = new Command('msg').description('消息中心 (通知 + 模板 CRUD, msgCenter)')
cmd.addCommand(buildMsgNoticeListCommand())
cmd.addCommand(buildMsgNoticeCreateCommand())
cmd.addCommand(buildMsgNoticeUpdateCommand())
cmd.addCommand(buildMsgNoticeDeleteCommand())
cmd.addCommand(buildMsgNoticeSendCommand())
cmd.addCommand(buildMsgTemplateListCommand())
cmd.addCommand(buildMsgTemplateCreateCommand())
cmd.addCommand(buildMsgTemplateUpdateCommand())
cmd.addCommand(buildMsgTemplateDeleteCommand())
return cmd
}
+42
View File
@@ -0,0 +1,42 @@
/**
* commands/msg/noticedelete.ts — 通知公告删除
*
* v0.11+ Phase 2 新增: msg 公告 CRUD 闭环
*
* API: DELETE /api/message/Notice/{id}
*/
import { Command } from 'commander'
import { JnpfClient } from '../../core/client.ts'
import { installAiHelpHook } from '../../core/help.ts'
import { log } from '../../core/log.ts'
interface Opts { id: string; yes?: boolean }
export function buildMsgNoticeDeleteCommand(): Command {
const cmd = new Command('noticeDelete')
.alias('notice-delete')
.description('通知公告删除 (硬删)')
.requiredOption('--id <id>', '公告 id')
.option('--yes', '跳过确认', false)
.action(async (opts: Opts) => {
if (!opts.yes) {
log.warn(`即将删除公告 id=${opts.id}, 加 --yes 跳过确认`)
process.exit(2)
}
const c = await JnpfClient.fromToken()
const r = await c.del(`/message/Notice/${opts.id}`)
if (r.code !== 200) {
log.error(`msg noticeDelete 失败: ${r.msg}`)
process.exit(1)
}
log.ok(`✓ 公告已删除 (id=${opts.id})`)
})
installAiHelpHook(cmd, {
purpose: '通知公告删除',
required: { '--id': '公告 id', '--yes': '跳过确认' },
example: 'dacli msg noticeDelete --id=123 --yes',
source: { api: 'DELETE /api/message/Notice/{id}' },
notes: ['v0.11+ P0 新增, 谨慎操作'],
})
return cmd
}
+63
View File
@@ -0,0 +1,63 @@
/**
* commands/msg/noticeupdate.ts — 通知公告修改
*
* v0.11+ Phase 2 新增: msg 公告 CRUD 闭环 (P0)
*
* API: PUT /api/message/Notice/{id}
*/
import { Command } from 'commander'
import { JnpfClient } from '../../core/client.ts'
import { installAiHelpHook } from '../../core/help.ts'
import { log, printJson } from '../../core/log.ts'
interface Opts {
id: string
fullName?: string
enCode?: string
body?: string
category?: string
json?: boolean
}
export function buildMsgNoticeUpdateCommand(): Command {
const cmd = new Command('noticeUpdate')
.alias('notice-update')
.description('通知公告修改 (PUT 语义)')
.requiredOption('--id <id>', '公告 id')
.option('--fullName <n>', '公告名')
.option('--enCode <e>', '英文编码')
.option('--body <text>', '公告内容')
.option('--category <c>', '分类 (1=系统 2=业务)')
.option('--json', '原始 JSON 输出', false)
.action(async (opts: Opts) => {
const c = await JnpfClient.fromToken()
const origR = await c.get<Record<string, unknown> | null>(`/message/Notice/${opts.id}`)
if (origR.code !== 200 || !origR.data) {
log.error(`msg noticeUpdate 失败: 拉原公告 id=${opts.id} 失败`)
process.exit(1)
}
const body: Record<string, unknown> = { ...(origR.data as Record<string, unknown>), id: opts.id }
if (opts.fullName) body.fullName = opts.fullName
if (opts.enCode) body.enCode = opts.enCode
if (opts.body) body.body = opts.body
if (opts.category) body.category = opts.category
log.info(`PUT /message/Notice/${opts.id}`)
const r = await c.putJson<unknown>(`/message/Notice/${opts.id}`, body)
if (r.code !== 200) {
log.error(`msg noticeUpdate 失败 (code=${r.code}): ${r.msg}`)
if (opts.json) printJson(r)
process.exit(1)
}
log.ok(`✓ 公告更新成功 (id=${opts.id})`)
if (opts.json) printJson(r.data)
})
installAiHelpHook(cmd, {
purpose: '通知公告修改. 改 fullName/enCode/body/category, PUT 语义, 未传保留.',
required: { '--id': '公告 id' },
optional: { '--fullName': '公告名', '--enCode': '英文编码', '--body': '公告内容', '--category': '分类' },
example: 'dacli msg noticeUpdate --id=123 --body="新内容"',
source: { api: 'PUT /api/message/Notice/{id}' },
notes: ['v0.11+ P0 新增', '未传字段保留 (PUT 语义)'],
})
return cmd
}
+42
View File
@@ -0,0 +1,42 @@
/**
* commands/msg/templatedelete.ts — 消息模板删除
*
* v0.11+ Phase 2 新增: msg 模板 CRUD 闭环
*
* API: DELETE /api/message/MessageTemplateConfig/{id}
*/
import { Command } from 'commander'
import { JnpfClient } from '../../core/client.ts'
import { installAiHelpHook } from '../../core/help.ts'
import { log } from '../../core/log.ts'
interface Opts { id: string; yes?: boolean }
export function buildMsgTemplateDeleteCommand(): Command {
const cmd = new Command('templateDelete')
.alias('template-delete')
.description('消息模板删除 (硬删)')
.requiredOption('--id <id>', '模板 id')
.option('--yes', '跳过确认', false)
.action(async (opts: Opts) => {
if (!opts.yes) {
log.warn(`即将删除模板 id=${opts.id}, 加 --yes 跳过确认`)
process.exit(2)
}
const c = await JnpfClient.fromToken()
const r = await c.del(`/message/MessageTemplateConfig/${opts.id}`)
if (r.code !== 200) {
log.error(`msg templateDelete 失败: ${r.msg}`)
process.exit(1)
}
log.ok(`✓ 模板已删除 (id=${opts.id})`)
})
installAiHelpHook(cmd, {
purpose: '消息模板删除',
required: { '--id': '模板 id', '--yes': '跳过确认' },
example: 'dacli msg templateDelete --id=123 --yes',
source: { api: 'DELETE /api/message/MessageTemplateConfig/{id}' },
notes: ['v0.11+ P0 新增, 谨慎操作'],
})
return cmd
}
+66
View File
@@ -0,0 +1,66 @@
/**
* commands/msg/templateupdate.ts — 消息模板修改
*
* v0.11+ Phase 2 新增: msg 模板 CRUD 闭环 (P0)
*
* API: PUT /api/message/MessageTemplateConfig/{id}
*/
import { Command } from 'commander'
import { JnpfClient } from '../../core/client.ts'
import { installAiHelpHook } from '../../core/help.ts'
import { log, printJson } from '../../core/log.ts'
interface Opts {
id: string
fullName?: string
enCode?: string
category?: string
content?: string
enabledMark?: string
json?: boolean
}
export function buildMsgTemplateUpdateCommand(): Command {
const cmd = new Command('templateUpdate')
.alias('template-update')
.description('消息模板修改 (PUT 语义)')
.requiredOption('--id <id>', '模板 id')
.option('--fullName <n>', '模板名')
.option('--enCode <e>', '英文编码')
.option('--category <c>', '分类 (1=系统 2=业务)')
.option('--content <text>', '模板内容')
.option('--enabledMark <0|1>', '启用/禁用')
.option('--json', '原始 JSON 输出', false)
.action(async (opts: Opts) => {
const c = await JnpfClient.fromToken()
const origR = await c.get<Record<string, unknown> | null>(`/message/MessageTemplateConfig/${opts.id}`)
if (origR.code !== 200 || !origR.data) {
log.error(`msg templateUpdate 失败: 拉原模板 id=${opts.id} 失败`)
process.exit(1)
}
const body: Record<string, unknown> = { ...(origR.data as Record<string, unknown>), id: opts.id }
if (opts.fullName) body.fullName = opts.fullName
if (opts.enCode) body.enCode = opts.enCode
if (opts.category) body.category = opts.category
if (opts.content) body.content = opts.content
if (opts.enabledMark !== undefined) body.enabledMark = parseInt(opts.enabledMark, 10)
log.info(`PUT /message/MessageTemplateConfig/${opts.id}`)
const r = await c.putJson<unknown>(`/message/MessageTemplateConfig/${opts.id}`, body)
if (r.code !== 200) {
log.error(`msg templateUpdate 失败 (code=${r.code}): ${r.msg}`)
if (opts.json) printJson(r)
process.exit(1)
}
log.ok(`✓ 模板更新成功 (id=${opts.id})`)
if (opts.json) printJson(r.data)
})
installAiHelpHook(cmd, {
purpose: '消息模板修改',
required: { '--id': '模板 id' },
optional: { '--fullName': '模板名', '--enCode': '英文编码', '--category': '分类', '--content': '内容', '--enabledMark': '启用/禁用' },
example: 'dacli msg templateUpdate --id=123 --content="新内容"',
source: { api: 'PUT /api/message/MessageTemplateConfig/{id}' },
notes: ['v0.11+ P0 新增', '未传字段保留 (PUT 语义)'],
})
return cmd
}
+41
View File
@@ -0,0 +1,41 @@
/**
* commands/schedule/delete.ts — 定时任务删除
*
* v0.11+ Phase 2 新增: 定时任务 CRUD 闭环
*
* API: DELETE /api/scheduletask/{id}
*/
import { Command } from 'commander'
import { JnpfClient } from '../../core/client.ts'
import { installAiHelpHook } from '../../core/help.ts'
import { log } from '../../core/log.ts'
interface Opts { id: string; yes?: boolean }
export function buildScheduleDeleteCommand(): Command {
const cmd = new Command('delete')
.description('定时任务删除 (硬删)')
.requiredOption('--id <id>', '任务 id')
.option('--yes', '跳过确认', false)
.action(async (opts: Opts) => {
if (!opts.yes) {
log.warn(`即将删除定时任务 id=${opts.id}, 加 --yes 跳过确认`)
process.exit(2)
}
const c = await JnpfClient.fromToken()
const r = await c.del(`/scheduletask/${opts.id}`)
if (r.code !== 200) {
log.error(`schedule delete 失败: ${r.msg}`)
process.exit(1)
}
log.ok(`✓ 定时任务已删除 (id=${opts.id})`)
})
installAiHelpHook(cmd, {
purpose: '定时任务删除. 任务调度会停.',
required: { '--id': '任务 id', '--yes': '跳过确认' },
example: 'dacli schedule delete --id=123 --yes',
source: { api: 'DELETE /api/scheduletask/{id}' },
notes: ['v0.11+ P0 新增, 谨慎操作'],
})
return cmd
}
+7 -1
View File
@@ -6,10 +6,12 @@
* 决策 9: 定时报表生成/数据清理/缓存刷新用 schedule (cron),
* 业务审批用 workflow (人工发起/事件触发)
*
* 子命令:
* v0.11+ Phase 2: 7 子命令 (闭环 CRUD)
* list 列表 (JNPF 端点已知返空, 用 info 兜底)
* info 详情
* create 新建
* update 修改 (P0 v0.11+, 改 cron 不必 delete+create)
* delete 删除 (P0 v0.11+)
* trigger 手动触发
* log 执行日志
*/
@@ -17,6 +19,8 @@ import { Command } from 'commander'
import { buildScheduleListCommand } from './list.ts'
import { buildScheduleInfoCommand } from './info.ts'
import { buildScheduleCreateCommand } from './create.ts'
import { buildScheduleUpdateCommand } from './update.ts'
import { buildScheduleDeleteCommand } from './delete.ts'
import { buildScheduleTriggerCommand } from './trigger.ts'
import { buildScheduleLogCommand } from './log.ts'
@@ -25,6 +29,8 @@ export function buildScheduleCommand(): Command {
cmd.addCommand(buildScheduleListCommand())
cmd.addCommand(buildScheduleInfoCommand())
cmd.addCommand(buildScheduleCreateCommand())
cmd.addCommand(buildScheduleUpdateCommand())
cmd.addCommand(buildScheduleDeleteCommand())
cmd.addCommand(buildScheduleTriggerCommand())
cmd.addCommand(buildScheduleLogCommand())
return cmd
+75
View File
@@ -0,0 +1,75 @@
/**
* commands/schedule/update.ts — 定时任务修改
*
* v0.11+ Phase 2 新增: 定时任务 CRUD 闭环 (P0, 改 cron 不必 delete+create)
*
* API: PUT /api/scheduletask/{id}
*/
import { Command } from 'commander'
import { JnpfClient } from '../../core/client.ts'
import { installAiHelpHook } from '../../core/help.ts'
import { log, printJson } from '../../core/log.ts'
interface Opts {
id: string
fullName?: string
enCode?: string
cron?: string
executeContent?: string
enabledMark?: string
json?: boolean
}
export function buildScheduleUpdateCommand(): Command {
const cmd = new Command('update')
.description('定时任务修改 (改 cron/executeContent/enabledMark, 避免 delete+create)')
.requiredOption('--id <id>', '任务 id')
.option('--fullName <n>', '任务名')
.option('--enCode <e>', '英文编码')
.option('--cron <c>', 'cron 表达式 (如 "0 0 * * * ?")')
.option('--executeContent <c>', '执行内容 (Quartz class 全名 + 参数)')
.option('--enabledMark <0|1>', '启用/禁用 (JNPF 无独立 pause/resume API, 用此替代)')
.option('--json', '原始 JSON 输出', false)
.action(async (opts: Opts) => {
const c = await JnpfClient.fromToken()
// 拉原任务
const origR = await c.get<Record<string, unknown> | null>(`/scheduletask/Info/${opts.id}`)
if (origR.code !== 200 || !origR.data) {
log.error(`schedule update 失败: 拉原任务 id=${opts.id} 失败 (id 不存在?)`)
process.exit(1)
}
const body: Record<string, unknown> = { ...(origR.data as Record<string, unknown>), id: opts.id }
if (opts.fullName) body.fullName = opts.fullName
if (opts.enCode) body.enCode = opts.enCode
if (opts.cron) body.cron = opts.cron
if (opts.executeContent) body.executeContent = opts.executeContent
if (opts.enabledMark !== undefined) body.enabledMark = parseInt(opts.enabledMark, 10)
log.info(`PUT /scheduletask/${opts.id}`)
const r = await c.putJson<unknown>(`/scheduletask/${opts.id}`, body)
if (r.code !== 200) {
log.error(`schedule update 失败 (code=${r.code}): ${r.msg}`)
if (opts.json) printJson(r)
process.exit(1)
}
log.ok(`✓ 定时任务更新成功 (id=${opts.id})`)
if (opts.json) printJson(r.data)
})
installAiHelpHook(cmd, {
purpose: '定时任务修改 (改 cron/executeContent/enabledMark, 避免 delete+create 浪费 + enCode 冲突风险).',
required: { '--id': '任务 id' },
optional: {
'--fullName': '任务名',
'--enCode': '英文编码',
'--cron': 'cron 表达式',
'--executeContent': '执行内容 (Quartz class + 参数)',
'--enabledMark': '启用/禁用 0|1 (替代 pause/resume)',
},
example: [
'dacli schedule update --id=123 --cron="0 0 2 * * ?"',
'dacli schedule update --id=123 --enabledMark=0 (禁用)',
],
source: { api: 'PUT /api/scheduletask/{id}' },
notes: ['v0.11+ P0 新增', 'enabledMark 替代 pause/resume (JNPF 无独立 API)'],
})
return cmd
}