feat(P19IM1-3,P19IM1-4): 接入业务事件与通知渠道后台

这个提交包含在:
2026-03-08 13:14:22 +08:00
父节点 f6d9f23553
当前提交 faff86c947
共修改 9 个文件,包含 1268 行新增和 135 行删除
+91
查看文件
@@ -0,0 +1,91 @@
import { apiRequestData } from "./http";
export type NotificationChannelType = "wecom" | "wechat_work";
export type NotificationChannelMode = "mock" | "wecom_webhook";
export type NotificationDomainScope =
| "workflow"
| "reimbursement"
| "leave"
| "procurement"
| "asset"
| "inventory";
export type NotificationChannelRouting = {
roleCodes: string[];
domainScopes: NotificationDomainScope[];
allowedTypes: string[];
};
export type NotificationChannelConfig = {
mode: NotificationChannelMode;
webhookUrl: string | null;
secret: string | null;
timeoutMs: number;
routing: NotificationChannelRouting;
};
export type NotificationChannelTemplate = {
title: string;
body: string;
footer: string;
deepLinkLabel: string;
};
export type NotificationChannel = {
id: string;
channelType: NotificationChannelType;
name: string;
enabled: boolean;
configJson: NotificationChannelConfig;
templateJson: NotificationChannelTemplate;
createdAt: string | null;
updatedAt: string | null;
};
export type NotificationChannelListResponse = {
items: NotificationChannel[];
};
export type NotificationChannelPayload = {
channelType: "wecom";
name: string;
enabled: boolean;
configJson: NotificationChannelConfig;
templateJson: NotificationChannelTemplate;
};
export type NotificationChannelTestResponse = {
channel: NotificationChannel;
testResult: {
ok: boolean;
code: string;
previewMessage: string | null;
response: unknown;
skipped: boolean;
};
};
export async function fetchNotificationChannels() {
return apiRequestData<NotificationChannelListResponse>("/api/notifications/channels");
}
export async function createNotificationChannel(payload: NotificationChannelPayload) {
return apiRequestData<{ channel: NotificationChannel }>("/api/notifications/channels", {
method: "POST",
body: JSON.stringify(payload),
});
}
export async function updateNotificationChannel(id: string, payload: Omit<NotificationChannelPayload, "channelType">) {
return apiRequestData<{ channel: NotificationChannel }>(`/api/notifications/channels/${id}`, {
method: "PATCH",
body: JSON.stringify(payload),
});
}
export async function testNotificationChannel(id: string) {
return apiRequestData<NotificationChannelTestResponse>(`/api/notifications/channels/${id}/test`, {
method: "POST",
body: JSON.stringify({}),
});
}