51 lines
1.6 KiB
TypeScript
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`)
|
|
}
|
|
}
|