use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use uuid::Uuid;
#[derive(Debug, Clone, Serialize, Deserialize, sqlx::FromRow)]
pub struct Tenant {
pub id: Uuid,
pub name: String,
pub slug: String,
pub encryption_key_id: String,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
pub deleted_at: Option<DateTime<Utc>>,
}
#[derive(Debug, Clone)]
pub struct TenantContext {
pub tenant_id: Uuid,
pub tenant_slug: String,
pub encryption_key_id: String,
}
impl TenantContext {
pub fn new(tenant_id: Uuid, tenant_slug: String, encryption_key_id: String) -> Self {
Self {
tenant_id,
tenant_slug,
encryption_key_id,
}
}
}
impl From<Tenant> for TenantContext {
fn from(tenant: Tenant) -> Self {
Self {
tenant_id: tenant.id,
tenant_slug: tenant.slug,
encryption_key_id: tenant.encryption_key_id,
}
}
}