use db::issue::issue_label as label_entity; use serde::{Deserialize, Serialize}; use time::OffsetDateTime; use time::format_description::well_known::Rfc3339; use utoipa::{IntoParams, ToSchema}; use uuid::Uuid; fn fmt_ts(ts: OffsetDateTime) -> String { ts.format(&Rfc3339).unwrap_or_default() } fn fmt_ts_opt(ts: Option) -> Option { ts.map(fmt_ts) } #[derive(Debug, Clone, Serialize, Deserialize, ToSchema)] pub struct LabelView { pub id: Uuid, pub channel_id: Uuid, pub name: String, pub exclusive: bool, pub exclusive_order: i32, pub description: Option, pub color: String, pub is_archived: bool, pub created_at: String, pub updated_at: Option, } impl From for LabelView { fn from(m: label_entity::Model) -> Self { Self { id: m.id, channel_id: m.channel_id, name: m.name, exclusive: m.exclusive, exclusive_order: m.exclusive_order, description: m.description, color: m.color, is_archived: m.is_archived, created_at: fmt_ts(m.created_at), updated_at: fmt_ts_opt(m.updated_at), } } } #[derive(Debug, Clone, Serialize, Deserialize, ToSchema)] pub struct LabelPage { pub items: Vec, pub total: i64, } #[derive(Debug, Clone, Serialize, Deserialize, ToSchema)] pub struct CreateLabelOption { pub name: String, pub color: String, pub exclusive: Option, pub exclusive_order: Option, pub description: Option, } #[derive(Debug, Clone, Serialize, Deserialize, ToSchema)] pub struct UpdateLabelOption { pub name: Option, pub color: Option, pub exclusive: Option, pub exclusive_order: Option, pub description: Option>, pub is_archived: Option, } #[derive(Debug, Clone, Serialize, Deserialize, ToSchema, IntoParams)] pub struct ListLabelQuery { pub q: Option, pub is_archived: Option, pub limit: Option, pub offset: Option, }