Files
kt-financial-system/apps/web-antd/src/api/core/telegram.ts
你的用户名 a06a964bab
Some checks failed
Deploy to Production / Build and Test (push) Has been cancelled
Deploy to Production / Deploy to Server (push) Has been cancelled
feat: add Telegram notification settings UI
2025-11-05 02:22:00 +08:00

71 lines
1.6 KiB
TypeScript

import { requestClient } from '#/api/request';
export namespace TelegramApi {
export interface NotificationConfig {
id: number;
name: string;
botToken: string;
chatId: string;
notificationTypes: string[];
isEnabled: boolean;
createdAt: string;
updatedAt: string;
}
export interface CreateNotificationConfigParams {
name: string;
botToken: string;
chatId: string;
notificationTypes?: string[];
isEnabled?: boolean;
}
export interface UpdateNotificationConfigParams {
name?: string;
botToken?: string;
chatId?: string;
notificationTypes?: string[];
isEnabled?: boolean;
}
export interface TestNotificationConfigParams {
botToken: string;
chatId: string;
}
}
export function getTelegramNotificationConfigs() {
return requestClient.get<TelegramApi.NotificationConfig[]>(
'/telegram/notifications',
);
}
export function createTelegramNotificationConfig(
data: TelegramApi.CreateNotificationConfigParams,
) {
return requestClient.post<TelegramApi.NotificationConfig>(
'/telegram/notifications',
data,
);
}
export function updateTelegramNotificationConfig(
id: number,
data: TelegramApi.UpdateNotificationConfigParams,
) {
return requestClient.put<TelegramApi.NotificationConfig>(
`/telegram/notifications/${id}`,
data,
);
}
export function deleteTelegramNotificationConfig(id: number) {
return requestClient.delete<{ id: number }>(`/telegram/notifications/${id}`);
}
export function testTelegramNotificationConfig(
data: TelegramApi.TestNotificationConfigParams,
) {
return requestClient.post<{ message: string }>('/telegram/test', data);
}