use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; use time::OffsetDateTime; use uuid::Uuid; #[derive( Debug, Clone, Copy, PartialEq, Eq, Default, EnumIter, DeriveActiveEnum, Serialize, Deserialize, )] #[sea_orm(rs_type = "i32", db_type = "SmallInteger")] pub enum PostStatus { #[default] Open = 0, Closed = 1, Archived = 2, Locked = 3, } #[sea_orm::model] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] #[sea_orm(table_name = "post")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: Uuid, #[sea_orm(unique_key = "collection_number")] pub collection_id: Uuid, #[sea_orm(unique_key = "collection_number")] pub autoincrement_id: i32, pub author_id: Uuid, pub title: String, pub body: String, pub status: PostStatus, pub is_pinned: bool, pub reply_count: i32, pub last_reply_at: Option, pub last_reply_by: Option, pub created_at: OffsetDateTime, pub updated_at: Option, pub closed_at: Option, pub archived_at: Option, #[sea_orm(belongs_to, from = "collection_id", to = "id")] pub collection: BelongsTo, #[sea_orm(belongs_to, from = "author_id", to = "uid")] pub author: BelongsTo, } impl ActiveModelBehavior for ActiveModel {}