gitdataai/libs/models/workspaces/workspace_alert_config.rs
ZhenYi fb91f5a6c5 feat(admin): add admin panel with billing alerts and model sync
- Add libs/api/admin with admin API endpoints:
  sync models, workspace credit, billing alert check
- Add workspace_alert_config model and alert service
- Add Session::no_op() for background tasks without user context
- Add admin/ Next.js admin panel (AI models, billing, workspaces, audit)
- Start billing alert background task every 30 minutes
2026-04-19 20:48:59 +08:00

31 lines
983 B
Rust

use crate::{DateTimeUtc, Decimal};
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "workspace_alert_config")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
#[sea_orm(column_name = "workspace_id")]
pub workspace_id: Uuid,
#[sea_orm(column_type = "Text")]
pub alert_type: String,
/// Threshold value (e.g. 10.0 = balance < $10, 0.8 = 80% of quota used)
#[sea_orm(column_type = "Decimal(Some((10, 4)))")]
pub threshold: Decimal,
#[sea_orm(default_value = "true")]
pub email_enabled: bool,
#[sea_orm(default_value = "true")]
pub enabled: bool,
/// admin_user.id (NULL if created via API without user context)
#[sea_orm(nullable)]
pub created_by: Option<i32>,
pub created_at: DateTimeUtc,
pub updated_at: DateTimeUtc,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
impl ActiveModelBehavior for ActiveModel {}