feat: Events API routes migrated to Rust

- GET /api/events — list with filters (type, read, pagination)
- GET /api/events/count — unread count
- POST /api/events/{id}/read — mark one as read
- POST /api/events/read-all — mark all as read
- DELETE /api/events — clear all events
- Event model with sqlx FromRow
This commit is contained in:
boos
2026-05-17 13:28:16 +08:00
parent 8568859da6
commit af05b40799
4 changed files with 130 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
use serde::{Deserialize, Serialize};
use sqlx::FromRow;
/// System event for admin notifications.
#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
pub struct Event {
pub id: i64,
#[sqlx(rename = "type")]
pub event_type: String,
pub title: String,
pub message: Option<String>,
pub level: Option<String>,
#[sqlx(rename = "read")]
pub is_read: Option<bool>,
pub related_id: Option<i64>,
pub related_type: Option<String>,
pub created_at: Option<String>,
}
+1
View File
@@ -2,6 +2,7 @@
pub mod account;
pub mod downstream_api_key;
pub mod event;
pub mod route_channel;
pub mod setting;
pub mod site;