auto(6f177c177d02): session end @ 2026-06-14T08:04:54 (+27f)
This commit is contained in:
1 parent
44c0d51907
commit
0fbc478e16
27 files changed
+60
-848
No files matched your search
+10
-10
@@ -6,18 +6,18 @@
|
||||
* 决策 8: 通知通道 site/email/sms/webhook/dingTalk/weCom
|
||||
*
|
||||
* 子命令:
|
||||
* notice-list 通知列表
|
||||
* notice-create 新建通知
|
||||
* notice-send 发送通知
|
||||
* template-list 模板列表
|
||||
* template-create 新建模板
|
||||
* noticelist 通知列表
|
||||
* noticecreate 新建通知
|
||||
* noticesend 发送通知
|
||||
* templatelist 模板列表
|
||||
* templatecreate 新建模板
|
||||
*/
|
||||
import { Command } from 'commander'
|
||||
import { buildMsgNoticeListCommand } from './notice-list.ts'
|
||||
import { buildMsgNoticeCreateCommand } from './notice-create.ts'
|
||||
import { buildMsgNoticeSendCommand } from './notice-send.ts'
|
||||
import { buildMsgTemplateListCommand } from './template-list.ts'
|
||||
import { buildMsgTemplateCreateCommand } from './template-create.ts'
|
||||
import { buildMsgNoticeListCommand } from './noticelist.ts'
|
||||
import { buildMsgNoticeCreateCommand } from './noticecreate.ts'
|
||||
import { buildMsgNoticeSendCommand } from './noticesend.ts'
|
||||
import { buildMsgTemplateListCommand } from './templatelist.ts'
|
||||
import { buildMsgTemplateCreateCommand } from './templatecreate.ts'
|
||||
|
||||
export function buildMsgCommand(): Command {
|
||||
const cmd = new Command('msg').description('消息中心 (通知 + 模板, msgCenter)')
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
/**
|
||||
* commands/msg/notice-create.ts — 新建通知公告
|
||||
*
|
||||
* API: POST /api/message/Notice
|
||||
*/
|
||||
import { Command } from 'commander'
|
||||
import { JnpfClient } from '../../core/client.ts'
|
||||
import { installAiHelpHook } from '../../core/help.ts'
|
||||
import { log, printJson } from '../../core/log.ts'
|
||||
|
||||
interface CreateOpts {
|
||||
fullName: string
|
||||
enCode: string
|
||||
body?: string
|
||||
json?: boolean
|
||||
}
|
||||
|
||||
export function buildMsgNoticeCreateCommand(): Command {
|
||||
const cmd = new Command('notice-create')
|
||||
.description('新建通知公告 (草稿, 未发布)')
|
||||
.requiredOption('--fullName <name>', '通知标题')
|
||||
.requiredOption('--enCode <code>', '通知编码')
|
||||
.option('--body <text>', '通知正文 (可选)')
|
||||
.option('--json', '原始 JSON 输出', false)
|
||||
.action(async (opts: CreateOpts) => {
|
||||
const c = await JnpfClient.fromToken()
|
||||
const body = {
|
||||
fullName: opts.fullName,
|
||||
enCode: opts.enCode,
|
||||
title: opts.fullName,
|
||||
body: opts.body || '通知内容',
|
||||
type: 1, // 1=系统公告 2=待办
|
||||
enabledMark: 1,
|
||||
sortCode: 0,
|
||||
}
|
||||
const r = await c.postJson<{ id?: string }>('/message/Notice', body)
|
||||
if (r.code !== 200) {
|
||||
log.error(`msg notice-create 失败 (code=${r.code}): ${r.msg}`)
|
||||
process.exit(1)
|
||||
}
|
||||
let id = r.data?.id
|
||||
if (!id) {
|
||||
const listR = await c.get<{ list: { id: string; enCode: string; fullName: string }[] }>(
|
||||
'/message/Notice',
|
||||
{ keyword: opts.enCode, pageSize: '50' },
|
||||
)
|
||||
const found = (listR.data?.list || []).find(
|
||||
(d) => d.enCode === opts.enCode || d.fullName === opts.fullName,
|
||||
)
|
||||
id = found?.id
|
||||
}
|
||||
log.info(`✓ 通知公告创建成功 id=${id}`)
|
||||
if (opts.json) printJson({ ...(r.data as object), id })
|
||||
})
|
||||
installAiHelpHook(cmd, {
|
||||
purpose: '新建通知公告 (草稿, 用 notice-release 发布)',
|
||||
required: { '--fullName': '通知标题', '--enCode': '通知编码' },
|
||||
optional: { '--body': '通知正文' },
|
||||
example: 'dacli msg notice-create --fullName=系统升级 --enCode=sys_upgrade_2026 --body=今晚 10 点维护',
|
||||
source: {
|
||||
web: 'web/apps/jnpf-web-apps-main/src/views/msgCenter/notice/Form.vue',
|
||||
api: 'POST /api/message/Notice',
|
||||
ref: 'doc/v0.8-endpoints.md §2.4',
|
||||
},
|
||||
})
|
||||
return cmd
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
/**
|
||||
* commands/msg/notice-list.ts — 通知公告列表
|
||||
*
|
||||
* API: GET /api/message/Notice 或 POST /api/message/Notice/List
|
||||
*/
|
||||
import { Command } from 'commander'
|
||||
import { JnpfClient } from '../../core/client.ts'
|
||||
import { installAiHelpHook } from '../../core/help.ts'
|
||||
import { log, printJson } from '../../core/log.ts'
|
||||
|
||||
interface NoticeItem {
|
||||
id?: string
|
||||
fullName?: string
|
||||
enCode?: string
|
||||
title?: string
|
||||
state?: number
|
||||
type?: number
|
||||
creatorTime?: string | number
|
||||
}
|
||||
|
||||
interface ListOpts {
|
||||
keyword?: string
|
||||
json?: boolean
|
||||
}
|
||||
|
||||
export function buildMsgNoticeListCommand(): Command {
|
||||
const cmd = new Command('notice-list')
|
||||
.description('列出通知公告 (站内信)')
|
||||
.option('--keyword <k>', '按名称/编码模糊搜索')
|
||||
.option('--json', '原始 JSON 输出', false)
|
||||
.action(async (opts: ListOpts) => {
|
||||
const c = await JnpfClient.fromToken()
|
||||
// JNPF Notice 列表用 POST /api/message/Notice/List (GET 返 405)
|
||||
const r = await c.postJson<{ list: NoticeItem[] }>('/message/Notice/List', {
|
||||
keyword: opts.keyword,
|
||||
currentPage: 1,
|
||||
pageSize: 50,
|
||||
})
|
||||
if (r.code !== 200) {
|
||||
log.error(`msg notice-list 失败 (code=${r.code}): ${r.msg}`)
|
||||
process.exit(1)
|
||||
}
|
||||
const list = r.data?.list || []
|
||||
if (opts.json) {
|
||||
printJson(r.data)
|
||||
return
|
||||
}
|
||||
log.info(`共 ${list.length} 个通知公告`)
|
||||
console.log('ID FULL_NAME ENCODE STATE')
|
||||
console.log('-'.repeat(85))
|
||||
for (const d of list) {
|
||||
const id = String(d.id || '').padEnd(30)
|
||||
const name = String(d.fullName || d.title || '').padEnd(23)
|
||||
const code = String(d.enCode || '').padEnd(21)
|
||||
const state = d.state === 1 ? '已发布' : '未发布'
|
||||
console.log(`${id}${name}${code}${state}`)
|
||||
}
|
||||
})
|
||||
installAiHelpHook(cmd, {
|
||||
purpose: '列出通知公告 (站内信, msgCenter)',
|
||||
optional: { '--keyword': '按名称/编码模糊搜索' },
|
||||
example: 'dacli msg notice-list\ndacli msg notice-list --keyword=系统',
|
||||
source: {
|
||||
web: 'web/apps/jnpf-web-apps-main/src/views/msgCenter/notice/index.vue',
|
||||
api: 'GET /api/message/Notice',
|
||||
ref: 'doc/v0.8-endpoints.md §2.4',
|
||||
},
|
||||
notes: [
|
||||
'**决策 8**: 站内信用 msgCenter (本命令), 邮件用 integrationCenter',
|
||||
'**send 通道**: 站内信 type=site, 邮件 type=email, 短信 type=sms, etc.',
|
||||
],
|
||||
})
|
||||
return cmd
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/**
|
||||
* commands/msg/notice-send.ts — 发送通知公告
|
||||
*
|
||||
* 注: 真实 "发送" 走 PUT /api/message/Notice/{id}/Actions/Release (发布后即推送)
|
||||
* 这里 provide 一个 "send" 别名, 内部走 release
|
||||
*/
|
||||
import { Command } from 'commander'
|
||||
import { JnpfClient } from '../../core/client.ts'
|
||||
import { installAiHelpHook } from '../../core/help.ts'
|
||||
import { log } from '../../core/log.ts'
|
||||
|
||||
interface SendOpts {
|
||||
id: string
|
||||
type?: string
|
||||
}
|
||||
|
||||
export function buildMsgNoticeSendCommand(): Command {
|
||||
const cmd = new Command('notice-send')
|
||||
.description('发布/发送通知 (走 release 端点, 决策 8: type=site 站内信)')
|
||||
.requiredOption('--id <id>', '通知 id')
|
||||
.option('--type <t>', '通道: site=站内信 (默认) | email=邮件 | sms=短信 | webhook=Webhook | dingTalk=钉钉 | weCom=企微', 'site')
|
||||
.action(async (opts: SendOpts) => {
|
||||
const validTypes = ['site', 'email', 'sms', 'webhook', 'dingTalk', 'weCom']
|
||||
if (!validTypes.includes(opts.type || '')) {
|
||||
log.error(`--type 必须是 ${validTypes.join('|')}`)
|
||||
process.exit(2)
|
||||
}
|
||||
const c = await JnpfClient.fromToken()
|
||||
// 站内信走 notice release
|
||||
if (opts.type === 'site') {
|
||||
const r = await c.putJson(`/message/Notice/${opts.id}/Actions/Release`, {})
|
||||
if (r.code !== 200) {
|
||||
log.error(`msg notice-send (站内信) 失败: ${r.msg}`)
|
||||
process.exit(1)
|
||||
}
|
||||
log.info(`✓ 通知 id=${opts.id} 已发布 (站内信推送)`)
|
||||
} else {
|
||||
// 邮件/短信/Webhook 走 integration 端点, 留 v0.9+ 实做
|
||||
log.warn(`--type=${opts.type} 通道的发送端点 v0.9+ 实做, 当前只支持 site (站内信)`)
|
||||
log.info(` 提示: 走 dacli integration ${opts.type} send (W12+)`)
|
||||
}
|
||||
})
|
||||
installAiHelpHook(cmd, {
|
||||
purpose: '发送/发布通知 (决策 8: 通道 site/email/sms/webhook/dingTalk/weCom)',
|
||||
required: { '--id': '通知 id' },
|
||||
optional: { '--type': '发送通道 (默认 site)' },
|
||||
example: 'dacli msg notice-send --id=1234567890\ndacli msg notice-send --id=1234567890 --type=email',
|
||||
source: {
|
||||
web: 'web/apps/jnpf-web-apps-main/src/views/msgCenter/notice/Form.vue',
|
||||
api: 'PUT /api/message/Notice/{id}/Actions/Release',
|
||||
ref: 'doc/v0.8-endpoints.md §2.4',
|
||||
},
|
||||
notes: [
|
||||
'**决策 8**: 当前只实做 site (站内信) 通道',
|
||||
'**v0.9+**: email/sms/webhook/dingTalk/weCom 通道走 dacli integration',
|
||||
],
|
||||
})
|
||||
return cmd
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
/**
|
||||
* commands/msg/template-create.ts — 新建消息模板
|
||||
*
|
||||
* API: POST /api/system/MessageTemplate
|
||||
*/
|
||||
import { Command } from 'commander'
|
||||
import { JnpfClient } from '../../core/client.ts'
|
||||
import { installAiHelpHook } from '../../core/help.ts'
|
||||
import { log, printJson } from '../../core/log.ts'
|
||||
|
||||
interface CreateOpts {
|
||||
fullName: string
|
||||
enCode: string
|
||||
json?: boolean
|
||||
}
|
||||
|
||||
export function buildMsgTemplateCreateCommand(): Command {
|
||||
const cmd = new Command('template-create')
|
||||
.description('新建消息模板')
|
||||
.requiredOption('--fullName <name>', '模板名称')
|
||||
.requiredOption('--enCode <code>', '模板编码')
|
||||
.option('--json', '原始 JSON 输出', false)
|
||||
.action(async (opts: CreateOpts) => {
|
||||
const c = await JnpfClient.fromToken()
|
||||
const body = {
|
||||
fullName: opts.fullName,
|
||||
enCode: opts.enCode,
|
||||
category: '1', // 1=系统 2=业务
|
||||
enabledMark: 1,
|
||||
sortCode: 0,
|
||||
}
|
||||
const r = await c.postJson<{ id?: string }>('/system/MessageTemplate', body)
|
||||
if (r.code !== 200) {
|
||||
log.error(`msg template-create 失败 (code=${r.code}): ${r.msg}`)
|
||||
process.exit(1)
|
||||
}
|
||||
let id = r.data?.id
|
||||
if (!id) {
|
||||
const listR = await c.get<{ list: { id: string; enCode: string; fullName: string }[] }>(
|
||||
'/system/MessageTemplate',
|
||||
{ keyword: opts.enCode, pageSize: '50' },
|
||||
)
|
||||
const found = (listR.data?.list || []).find(
|
||||
(d) => d.enCode === opts.enCode || d.fullName === opts.fullName,
|
||||
)
|
||||
id = found?.id
|
||||
}
|
||||
log.info(`✓ 消息模板创建成功 id=${id}`)
|
||||
if (opts.json) printJson({ ...(r.data as object), id })
|
||||
})
|
||||
installAiHelpHook(cmd, {
|
||||
purpose: '新建消息模板',
|
||||
required: { '--fullName': '模板名称', '--enCode': '模板编码' },
|
||||
example: 'dacli msg template-create --fullName=系统告警模板 --enCode=sys_alert',
|
||||
source: {
|
||||
web: 'web/apps/jnpf-web-apps-main/src/views/msgCenter/msgTemplate/Form.vue',
|
||||
api: 'POST /api/system/MessageTemplate',
|
||||
ref: 'doc/v0.8-endpoints.md §2.4',
|
||||
},
|
||||
})
|
||||
return cmd
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
/**
|
||||
* commands/msg/template-list.ts — 消息模板列表
|
||||
*
|
||||
* API: GET /api/system/MessageTemplate
|
||||
*/
|
||||
import { Command } from 'commander'
|
||||
import { JnpfClient } from '../../core/client.ts'
|
||||
import { installAiHelpHook } from '../../core/help.ts'
|
||||
import { log, printJson } from '../../core/log.ts'
|
||||
|
||||
interface TemplateItem {
|
||||
id?: string
|
||||
fullName?: string
|
||||
enCode?: string
|
||||
category?: string
|
||||
enabledMark?: number
|
||||
}
|
||||
|
||||
interface ListOpts {
|
||||
keyword?: string
|
||||
json?: boolean
|
||||
}
|
||||
|
||||
export function buildMsgTemplateListCommand(): Command {
|
||||
const cmd = new Command('template-list')
|
||||
.description('列出消息模板 (站内信/邮件/短信/Webhook 模板)')
|
||||
.option('--keyword <k>', '按名称/编码模糊搜索')
|
||||
.option('--json', '原始 JSON 输出', false)
|
||||
.action(async (opts: ListOpts) => {
|
||||
const c = await JnpfClient.fromToken()
|
||||
// web msgTemplate.ts: Prefix = '/api/message/MessageTemplateConfig'
|
||||
const r = await c.get<{ list: TemplateItem[] }>('/message/MessageTemplateConfig', {
|
||||
keyword: opts.keyword,
|
||||
currentPage: 1,
|
||||
pageSize: 50,
|
||||
})
|
||||
if (r.code !== 200) {
|
||||
log.error(`msg template-list 失败 (code=${r.code}): ${r.msg}`)
|
||||
process.exit(1)
|
||||
}
|
||||
const list = r.data?.list || []
|
||||
if (opts.json) {
|
||||
printJson(r.data)
|
||||
return
|
||||
}
|
||||
log.info(`共 ${list.length} 个消息模板`)
|
||||
console.log('ID FULL_NAME ENCODE ENABLED')
|
||||
console.log('-'.repeat(85))
|
||||
for (const d of list) {
|
||||
const id = String(d.id || '').padEnd(30)
|
||||
const name = String(d.fullName || '').padEnd(23)
|
||||
const code = String(d.enCode || '').padEnd(21)
|
||||
const en = d.enabledMark === 1 ? '是' : '否'
|
||||
console.log(`${id}${name}${code}${en}`)
|
||||
}
|
||||
})
|
||||
installAiHelpHook(cmd, {
|
||||
purpose: '列出消息模板 (站内信/邮件/短信 模板)',
|
||||
optional: { '--keyword': '按名称/编码模糊搜索' },
|
||||
example: 'dacli msg template-list\ndacli msg template-list --keyword=告警',
|
||||
source: {
|
||||
web: 'web/apps/jnpf-web-apps-main/src/views/msgCenter/msgTemplate/index.vue',
|
||||
api: 'GET /api/message/MessageTemplateConfig',
|
||||
ref: 'doc/v0.8-endpoints.md §2.4',
|
||||
},
|
||||
})
|
||||
return cmd
|
||||
}
|
||||
Reference in new issue
Block a user