2025-08-16 18:13:03 -03:00
|
|
|
use chrono::{DateTime, Utc};
|
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
use sqlx::FromRow;
|
|
|
|
|
use uuid::Uuid;
|
|
|
|
|
|
2025-10-05 10:20:42 -03:00
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
|
|
|
|
|
pub struct organization {
|
|
|
|
|
pub org_id: Uuid,
|
|
|
|
|
pub name: String,
|
|
|
|
|
pub slug: String,
|
|
|
|
|
pub created_at: DateTime<Utc>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
|
|
|
|
|
pub struct Bot {
|
|
|
|
|
pub bot_id: Uuid,
|
|
|
|
|
pub name: String,
|
|
|
|
|
pub status: BotStatus,
|
|
|
|
|
pub config: serde_json::Value,
|
|
|
|
|
pub created_at: chrono::DateTime<Utc>,
|
|
|
|
|
pub updated_at: chrono::DateTime<Utc>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, sqlx::Type)]
|
|
|
|
|
#[serde(rename_all = "snake_case")]
|
|
|
|
|
#[sqlx(type_name = "bot_status", rename_all = "snake_case")]
|
|
|
|
|
pub enum BotStatus {
|
|
|
|
|
Active,
|
|
|
|
|
Inactive,
|
|
|
|
|
Maintenance,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
use chrono::{DateTime, Utc};
|
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
use sqlx::FromRow;
|
|
|
|
|
use uuid::Uuid;
|
|
|
|
|
|
2025-08-16 18:13:03 -03:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
|
|
|
|
pub enum TriggerKind {
|
|
|
|
|
Scheduled = 0,
|
|
|
|
|
TableUpdate = 1,
|
|
|
|
|
TableInsert = 2,
|
|
|
|
|
TableDelete = 3,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl TriggerKind {
|
|
|
|
|
pub fn from_i32(value: i32) -> Option<Self> {
|
|
|
|
|
match value {
|
|
|
|
|
0 => Some(Self::Scheduled),
|
|
|
|
|
1 => Some(Self::TableUpdate),
|
|
|
|
|
2 => Some(Self::TableInsert),
|
|
|
|
|
3 => Some(Self::TableDelete),
|
|
|
|
|
_ => None,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, FromRow, Serialize, Deserialize)]
|
|
|
|
|
pub struct Automation {
|
|
|
|
|
pub id: Uuid,
|
|
|
|
|
pub kind: i32, // Using number for trigger type
|
|
|
|
|
pub target: Option<String>,
|
|
|
|
|
pub schedule: Option<String>,
|
|
|
|
|
pub param: String,
|
|
|
|
|
pub is_active: bool,
|
|
|
|
|
pub last_triggered: Option<DateTime<Utc>>,
|
|
|
|
|
}
|