use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; use time::OffsetDateTime; #[derive( Debug, Clone, Copy, PartialEq, Eq, Default, EnumIter, DeriveActiveEnum, Serialize, Deserialize, )] #[sea_orm(rs_type = "i16", db_type = "SmallInteger")] pub enum StickerKind { #[default] #[sea_orm(num_value = 0)] Emoji = 0, #[sea_orm(num_value = 1)] Sticker = 1, } #[sea_orm::model] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] #[sea_orm(table_name = "sticker")] pub struct Model { #[sea_orm(primary_key)] pub id: Uuid, #[sea_orm(unique_key = "space_name")] pub space_id: Uuid, #[sea_orm(unique_key = "space_name")] pub name: String, pub pack_id: Option, pub kind: StickerKind, pub url: String, pub content_type: String, pub size: i64, pub width: Option, pub height: Option, #[sea_orm(default_value = "false")] pub is_animated: bool, pub created_by: Option, pub created_at: OffsetDateTime, #[sea_orm(belongs_to, from = "space_id", to = "id")] pub space: BelongsTo, #[sea_orm(belongs_to, from = "pack_id", to = "id")] pub pack: BelongsTo>, #[sea_orm(belongs_to, from = "created_by", to = "uid")] pub creator: BelongsTo>, } impl ActiveModelBehavior for ActiveModel {}