Files
one-pipe-system/src/api/modules/notification.ts
luo 9289a6e940
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 4m5s
feat: 完善接口19-顶部通知铃铛与站内通知中心
2026-07-25 10:20:53 +08:00

51 lines
1.6 KiB
TypeScript

import { BaseService } from '../BaseService'
import type {
BaseResponse,
NotificationListResponse,
NotificationQueryParams,
NotificationReadAllRequest,
NotificationReadAllResponse,
NotificationReadResponse,
NotificationUnreadCount,
NotificationUnreadSummary,
NotificationTarget
} from '@/types/api'
export class NotificationService extends BaseService {
static getUnreadCount(): Promise<BaseResponse<NotificationUnreadCount>> {
return this.get<BaseResponse<NotificationUnreadCount>>('/api/admin/notifications/unread-count')
}
static getUnreadSummary(): Promise<BaseResponse<NotificationUnreadSummary>> {
return this.get<BaseResponse<NotificationUnreadSummary>>(
'/api/admin/notifications/unread-summary'
)
}
static getNotifications(
params?: NotificationQueryParams
): Promise<BaseResponse<NotificationListResponse>> {
return this.get<BaseResponse<NotificationListResponse>>('/api/admin/notifications', params)
}
static markRead(id: number): Promise<BaseResponse<NotificationReadResponse>> {
return this.put<BaseResponse<NotificationReadResponse>>(
`/api/admin/notifications/${id}/read`,
{}
)
}
static markAllRead(
data: NotificationReadAllRequest = {}
): Promise<BaseResponse<NotificationReadAllResponse>> {
return this.put<BaseResponse<NotificationReadAllResponse>>(
'/api/admin/notifications/read-all',
data
)
}
static getTarget(id: number): Promise<BaseResponse<NotificationTarget>> {
return this.get<BaseResponse<NotificationTarget>>(`/api/admin/notifications/${id}/target`)
}
}