//! Account 表相关模型 use sqlx::FromRow; /// accounts 表完整行 (含 last_login_at) #[derive(Debug, FromRow)] pub struct AccountRow { pub id: String, pub username: String, pub email: String, pub display_name: String, pub role: String, pub status: String, pub totp_enabled: bool, pub last_login_at: Option, pub created_at: String, pub llm_routing: String, } /// accounts 表行 (不含 last_login_at,用于 auth/me 等场景) #[derive(Debug, FromRow)] pub struct AccountAuthRow { pub id: String, pub username: String, pub email: String, pub display_name: String, pub role: String, pub status: String, pub totp_enabled: bool, pub created_at: String, pub llm_routing: String, } /// Login 一次性查询行(合并用户信息 + password_hash + totp_secret + 安全字段) #[derive(Debug, FromRow)] pub struct AccountLoginRow { pub id: String, pub username: String, pub email: String, pub display_name: String, pub role: String, pub status: String, pub totp_enabled: bool, pub password_hash: String, pub totp_secret: Option, pub created_at: String, pub llm_routing: String, pub password_version: i32, pub failed_login_count: i32, pub locked_until: Option, } /// operation_logs 表行 #[derive(Debug, FromRow)] pub struct OperationLogRow { pub id: i64, pub account_id: Option, pub action: String, pub target_type: Option, pub target_id: Option, pub details: Option, pub ip_address: Option, pub created_at: String, } /// Dashboard 统计聚合行 #[derive(Debug, FromRow)] pub struct DashboardStatsRow { pub total_accounts: i64, pub active_accounts: i64, pub active_providers: i64, pub active_models: i64, } /// Dashboard 今日统计聚合行 #[derive(Debug, FromRow)] pub struct DashboardTodayRow { pub tasks_today: i64, pub tokens_input: i64, pub tokens_output: i64, }