From 763783b984c318c7577ce562b199928155a0673c Mon Sep 17 00:00:00 2001 From: Timi Date: Thu, 20 Aug 2026 22:58:53 +0800 Subject: [PATCH] add Notify --- src/api/NotifyAPI.ts | 35 +++++++++++++++++++++++++++ src/api/index.ts | 1 + src/types/Notify.ts | 57 ++++++++++++++++++++++++++++++++++++++++++++ src/types/index.ts | 1 + 4 files changed, 94 insertions(+) create mode 100644 src/api/NotifyAPI.ts create mode 100644 src/types/Notify.ts diff --git a/src/api/NotifyAPI.ts b/src/api/NotifyAPI.ts new file mode 100644 index 0000000..a5aac64 --- /dev/null +++ b/src/api/NotifyAPI.ts @@ -0,0 +1,35 @@ +import { axios } from "./BaseAPI"; +import type { NotifyDetail, Page, PageResult } from "../types"; + +const BASE_URI = "/notify/internal"; + +/** 查询当前用户的站内通知。 */ +async function listInternal(page?: Page, unreadOnly = false): Promise> { + return await axios.post(`${BASE_URI}/internal`, page, { + params: { unreadOnly } + }); +} + +/** 查询当前用户未读站内通知数量。 */ +async function countUnreadInternal(): Promise { + return await axios.post(`${BASE_URI}/unread/count`); +} + +/** 标记当前用户的一条站内通知已读。 */ +async function markInternalRead(id: string): Promise { + await axios.post(`${BASE_URI}/read`, undefined, { + params: { id } + }); +} + +/** 标记当前用户全部站内通知已读。 */ +async function markAllInternalRead(): Promise { + await axios.post(`${BASE_URI}/read/all`); +} + +export default { + listInternal, + countUnreadInternal, + markInternalRead, + markAllInternalRead +}; diff --git a/src/api/index.ts b/src/api/index.ts index ce114c8..41debfb 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -3,6 +3,7 @@ export { default as AttachmentAPI } from "./AttachmentAPI"; export { default as CommentAPI } from "./CommentAPI"; export { default as CommonAPI } from "./CommonAPI"; export { default as DeveloperAPI } from "./DeveloperAPI"; +export { default as NotifyAPI } from "./NotifyAPI"; export { default as PermissionAPI } from "./PermissionAPI"; export { default as RoleAPI } from "./RoleAPI"; export { default as UserAPI } from "./UserAPI"; diff --git a/src/types/Notify.ts b/src/types/Notify.ts new file mode 100644 index 0000000..f699549 --- /dev/null +++ b/src/types/Notify.ts @@ -0,0 +1,57 @@ +import type { Model } from "./Model"; + +/** 通知消息类型 */ +export type NotifyMsgType = "INTERNAL" | "SMS" | "MAIL" | "HTTP" | "WECHAT"; + +/** 通知投递状态 */ +export type NotifyStatus = "WAITING" | "REMINDED" | "TIMEOUT" | "CANCEL" | "FAIL"; + +/** 通知 */ +export type Notify = { + /** 业务类型 */ + bizType?: string; + /** 提醒业务类型 */ + bizRemindedType?: string; + /** 提醒业务 ID */ + bizRemindedId?: string; + /** 参数 */ + args?: string; + /** 创建者 */ + createdBy?: string; + /** 通知详情列表 */ + detailList?: NotifyDetail[]; +} & Model; + +/** 通知详情 */ +export type NotifyDetail = { + /** 所属通知 ID */ + notifyId?: string; + /** 消息类型 */ + msgType?: NotifyMsgType; + /** 模板 ID */ + templateId?: string; + /** 标题 */ + subject?: string; + /** 内容 */ + data?: string; + /** 参数 */ + args?: string; + /** 发送来源 */ + sendFrom?: string; + /** 发送去向 */ + sendTo?: string; + /** 发送时间 */ + sendAt?: number; + /** 重试计数 */ + retry?: number; + /** 超时时间 */ + timeoutAt?: number; + /** 结果描述 */ + resultDesc?: string; + /** 投递状态 */ + status?: NotifyStatus; + /** 已读时间,站内通知未读时为空 */ + readAt?: number; + /** 所属通知 */ + notify?: Notify; +} & Model; diff --git a/src/types/index.ts b/src/types/index.ts index bd79f5a..dcbf26a 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -10,6 +10,7 @@ export * from "./Role"; export * from "./User"; export * from "./Comment"; export * from "./Developer"; +export * from "./Notify"; /** * 安装方法