Files
tyc-admin/apps/web-antd/src/api/notification/index.ts

106 lines
2.0 KiB
TypeScript
Raw Normal View History

2025-05-27 18:35:06 +08:00
import type { Recordable } from '@vben/types';
import { requestClient } from '#/api/request';
export namespace NotificationApi {
export interface NotificationItem {
id: number;
title: string;
content?: string;
notification_page: string;
start_date: string;
start_time: string;
end_date: string;
end_time: string;
status: number;
create_time: string;
update_time: string;
}
export interface NotificationList {
total: number;
items: NotificationItem[];
}
export interface CreateNotificationRequest {
title: string;
content: string;
notification_page: string;
start_date: string;
start_time: string;
end_date: string;
end_time: string;
status: 0 | 1;
}
export interface CreateNotificationResponse {
id: number;
}
export interface UpdateNotificationRequest
extends Partial<CreateNotificationRequest> {
id: number;
}
export interface UpdateNotificationResponse {
success: boolean;
}
export interface DeleteNotificationResponse {
success: boolean;
}
}
/**
*
*/
async function getNotificationList(params: Recordable<any>) {
return requestClient.get<NotificationApi.NotificationList>(
'/notification/list',
{
params,
},
);
}
/**
*
*/
async function createNotification(
data: NotificationApi.CreateNotificationRequest,
) {
return requestClient.post<NotificationApi.CreateNotificationResponse>(
'/notification/create',
data,
);
}
/**
*
*/
async function updateNotification(
id: number,
data: NotificationApi.UpdateNotificationRequest,
) {
return requestClient.put<NotificationApi.UpdateNotificationResponse>(
`/notification/update/${id}`,
data,
);
}
/**
*
*/
async function deleteNotification(id: number) {
return requestClient.delete<NotificationApi.DeleteNotificationResponse>(
`/notification/delete/${id}`,
);
}
export {
createNotification,
deleteNotification,
getNotificationList,
updateNotification,
};