- Add llm_routing to all list_accounts/get_account SQL queries and JSON responses - Add llm_routing to UpdateAccountRequest with COALESCE update - Add llm_routing to AccountPublic struct in auth types - Wire llm_routing into register (default 'local'), login, and me handlers - Add llm_routing field to AccountRow, AccountAuthRow, AccountLoginRow model structs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
79 lines
1.9 KiB
Rust
79 lines
1.9 KiB
Rust
//! 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<String>,
|
||
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<String>,
|
||
pub created_at: String,
|
||
pub llm_routing: String,
|
||
}
|
||
|
||
/// operation_logs 表行
|
||
#[derive(Debug, FromRow)]
|
||
pub struct OperationLogRow {
|
||
pub id: i64,
|
||
pub account_id: Option<String>,
|
||
pub action: String,
|
||
pub target_type: Option<String>,
|
||
pub target_id: Option<String>,
|
||
pub details: Option<String>,
|
||
pub ip_address: Option<String>,
|
||
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,
|
||
}
|