✨ 新功能: - 添加Telegram Bot通知支持 - 账目记录自动推送到Telegram - 支持多个Bot配置管理 - 支持群组和个人通知 📊 数据库: - 新增telegram_notification_configs表 - 存储Bot配置和通知类型 🔧 后端API: - GET /api/telegram/notifications - 获取所有配置 - POST /api/telegram/notifications - 创建配置 - PUT /api/telegram/notifications/:id - 更新配置 - DELETE /api/telegram/notifications/:id - 删除配置 - POST /api/telegram/test - 测试Bot配置 💬 通知功能: - 自动发送账目记录通知 - 包含交易类型、金额、分类、账户等信息 - 支持格式化显示(类型图标、状态标识) - 配置创建时自动测试有效性 📝 文档: - 添加完整的使用说明文档 - API接口说明和示例 - 常见问题解答
28 lines
874 B
TypeScript
28 lines
874 B
TypeScript
import db from '~/utils/sqlite';
|
|
import { useResponseSuccess } from '~/utils/response';
|
|
|
|
export default defineEventHandler(() => {
|
|
const configs = db
|
|
.prepare<{ id: number; name: string; bot_token: string; chat_id: string; notification_types: string; is_enabled: number; created_at: string; updated_at: string }>(
|
|
`
|
|
SELECT id, name, bot_token, chat_id, notification_types, is_enabled, created_at, updated_at
|
|
FROM telegram_notification_configs
|
|
ORDER BY created_at DESC
|
|
`,
|
|
)
|
|
.all();
|
|
|
|
const result = configs.map((row) => ({
|
|
id: row.id,
|
|
name: row.name,
|
|
botToken: row.bot_token,
|
|
chatId: row.chat_id,
|
|
notificationTypes: JSON.parse(row.notification_types) as string[],
|
|
isEnabled: row.is_enabled === 1,
|
|
createdAt: row.created_at,
|
|
updatedAt: row.updated_at,
|
|
}));
|
|
|
|
return useResponseSuccess(result);
|
|
});
|