eeff292
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,
utoipa::ToSchema,
)]
#[serde(rename_all = "snake_case")]
#[sea_orm(rs_type = "i16", db_type = "SmallInteger")]
pub enum IssuePriority {
#[default]
#[sea_orm(num_value = 0)]
None,
#[sea_orm(num_value = 1)]
Low,
#[sea_orm(num_value = 2)]
Medium,
#[sea_orm(num_value = 3)]
High,
#[sea_orm(num_value = 4)]
Urgent,
}
#[sea_orm::model]
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "issue")]
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: i64,
pub title: String,
pub description: Option<String>,
pub body: String,
pub milestone_id: Option<Uuid>,
#[sea_orm(default_value = 0)]
pub priority: IssuePriority,
pub due_at: Option<OffsetDateTime>,
pub created_at: OffsetDateTime,
pub updated_at: Option<OffsetDateTime>,
pub closed_at: Option<OffsetDateTime>,
#[sea_orm(belongs_to, from = "collection_id", to = "id")]
pub collection: BelongsTo<super::issues::Entity>,
#[sea_orm(belongs_to, from = "author_id", to = "uid")]
pub author: BelongsTo<super::super::users::user::Entity>,
#[sea_orm(belongs_to, from = "milestone_id", to = "id")]
pub milestone: BelongsTo<Option<super::milestone::Entity>>,
}
impl ActiveModelBehavior for ActiveModel {}