消息列表
This commit is contained in:
63
src/services/noticeService.ts
Normal file
63
src/services/noticeService.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import httpService from "./httpService";
|
||||
import type { ApiResponse } from "./httpService";
|
||||
|
||||
export enum ReadStatus {
|
||||
UNREAD = 0,
|
||||
READ = 1
|
||||
}
|
||||
|
||||
export interface NoticeListParams {
|
||||
notification_type?: string;
|
||||
is_read?: ReadStatus;
|
||||
}
|
||||
|
||||
export interface NoticeListResponse {
|
||||
list: any[];
|
||||
total: number;
|
||||
unread_count: number;
|
||||
}
|
||||
|
||||
export interface Notice {
|
||||
description: string;
|
||||
}
|
||||
|
||||
export interface MarkReadParams {
|
||||
notification_ids: number[];
|
||||
mark_all: boolean;
|
||||
}
|
||||
|
||||
export interface DeleteParams {
|
||||
notification_ids: number[];
|
||||
delete_all: boolean;
|
||||
}
|
||||
|
||||
export interface UnreadMountResponse {
|
||||
total_unread: number;
|
||||
unread_by_type: {}
|
||||
}
|
||||
|
||||
|
||||
class NoticeService {
|
||||
// 获取用户消息通知列表
|
||||
async getNotificationList({ notification_type, is_read }: NoticeListParams): Promise<ApiResponse<NoticeListResponse>> {
|
||||
return httpService.post("/notifications/list", { notification_type, is_read }, { showLoading: true });
|
||||
}
|
||||
// 获取消息通知详情
|
||||
async getNotificationDetail(notification_id: number): Promise<ApiResponse<Notice>> {
|
||||
return httpService.post("/notifications/detail", { notification_id }, { showLoading: true });
|
||||
}
|
||||
// 标记消息为已读
|
||||
async markNotificationRead({ notification_ids, mark_all }: MarkReadParams): Promise<ApiResponse<{ marked_count: number }>> {
|
||||
return httpService.post("/notifications/mark_read", { notification_ids, mark_all }, { showLoading: true });
|
||||
}
|
||||
// 删除消息通知
|
||||
async delNotification({ notification_ids, delete_all }: DeleteParams): Promise<ApiResponse<{ deleted_count: number }>> {
|
||||
return httpService.post("/notifications/delete", { notification_ids, delete_all }, { showLoading: true });
|
||||
}
|
||||
// 获取未读消息数量
|
||||
async getNotificationUnreadCount(): Promise<ApiResponse<UnreadMountResponse>> {
|
||||
return httpService.post("/notifications/unread_count", {}, { showLoading: true });
|
||||
}
|
||||
}
|
||||
|
||||
export default new NoticeService();
|
||||
Reference in New Issue
Block a user