use actix_cloud_codegen::{entity_behavior, entity_id, entity_timestamp};
use anyhow::Result;
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
use crate::HyUuid;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default, Serialize, Deserialize)]
#[sea_orm(table_name = "webpush_clients")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: HyUuid,
pub uid: HyUuid,
pub endpoint: String,
pub p256dh: String,
pub auth: String,
pub lang: String,
pub created_at: i64,
pub updated_at: i64,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::users::Entity",
from = "Column::Uid",
to = "super::users::Column::Id"
)]
User,
}
impl Related<super::users::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
#[entity_id(HyUuid::new())]
#[entity_timestamp]
impl ActiveModel {}
#[entity_behavior]
impl ActiveModelBehavior for ActiveModel {}