diff --git a/build.gradle b/build.gradle index bd20214..7aee8c4 100644 --- a/build.gradle +++ b/build.gradle @@ -26,6 +26,7 @@ repositories { dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-validation' + implementation 'org.springframework.boot:spring-boot-starter-mail' implementation 'org.springframework.security:spring-security-crypto' implementation 'com.baomidou:mybatis-plus-spring-boot3-starter:3.5.12' diff --git a/frontend/src/api/notification.ts b/frontend/src/api/notification.ts new file mode 100644 index 0000000..259160d --- /dev/null +++ b/frontend/src/api/notification.ts @@ -0,0 +1,105 @@ +// 定时通知相关 API 接口:提醒周期配置、推送渠道管理与发送日志 +import request from './request' + +/** 通知周期配置 */ +export interface NotificationConfig { + enabled: boolean + frequency: string + dayOfMonth: number + dayOfWeek: number + sendTime: string + lastSentAt: string | null +} + +/** 通知渠道 */ +export interface NotificationChannel { + id: number + type: string + name: string + enabled: boolean + config: Record + hasPassword: boolean + createdAt: string + updatedAt: string +} + +/** 通知发送日志 */ +export interface NotificationLog { + id: number + channelId: number | null + channelType: string | null + success: boolean + message: string | null + createdAt: string +} + +/** 获取当前用户的通知配置 */ +export function getNotificationConfig() { + return request.get('/notification/config') +} + +/** 保存当前用户的通知配置 */ +export function saveNotificationConfig(data: { + enabled: boolean + frequency: string + dayOfMonth: number + dayOfWeek: number + sendTime: string +}) { + return request.put('/notification/config', data) +} + +/** 查询通知渠道列表 */ +export function listNotificationChannels() { + return request.get('/notification/channels') +} + +/** 新增通知渠道 */ +export function createNotificationChannel(data: { + type: string + name: string + enabled: boolean + config: Record +}) { + return request.post('/notification/channels', data) +} + +/** 修改通知渠道,邮箱授权码留空表示不修改 */ +export function updateNotificationChannel(id: number, data: { + type: string + name: string + enabled: boolean + config: Record +}) { + return request.put(`/notification/channels/${id}`, data) +} + +/** 删除通知渠道 */ +export function deleteNotificationChannel(id: number) { + return request.delete(`/notification/channels/${id}`) +} + +/** 向指定渠道发送测试消息(耗时取决于渠道,放宽超时) */ +export function testNotificationChannel(id: number) { + return request.post(`/notification/channels/${id}/test`, {}, { timeout: 60000 }) +} + +/** 立即向所有已启用渠道发送账单导入提醒 */ +export function sendNotificationNow() { + return request.post('/notification/send-now', {}, { timeout: 60000 }) +} + +/** 查询最近的发送日志 */ +export function listNotificationLogs(limit = 20) { + return request.get('/notification/logs', { params: { limit } }) +} + +/** 获取通知链接地址(全局应用配置) */ +export function getNotificationUrl() { + return request.get('/app/notification-url') +} + +/** 保存通知链接地址(全局应用配置) */ +export function updateNotificationUrl(url: string) { + return request.put('/app/notification-url', { url }) +} diff --git a/frontend/src/components/AiConfigPanel.vue b/frontend/src/components/AiConfigPanel.vue index 9b8a034..feadb86 100644 --- a/frontend/src/components/AiConfigPanel.vue +++ b/frontend/src/components/AiConfigPanel.vue @@ -146,7 +146,7 @@ onMounted(loadConfig) - + - +