use serde::{Deserialize, Serialize}; use sqlx::FromRow; use uuid::Uuid; use chrono::{DateTime, Utc}; #[derive(Debug, Clone, Serialize, Deserialize, sqlx::Type)] #[sqlx(type_name = "proposal_status", rename_all = "lowercase")] pub enum ProposalStatus { Draft, Discussion, Voting, Closed, Archived, } #[derive(Debug, Clone, Serialize, Deserialize, sqlx::Type)] #[sqlx(type_name = "deliberation_phase", rename_all = "lowercase")] pub enum DeliberationPhase { Drafting, Informing, Discussing, Voting, Concluded, } #[derive(Debug, Clone, Serialize, Deserialize, FromRow)] pub struct Proposal { pub id: Uuid, pub community_id: Uuid, pub author_id: Uuid, pub title: String, pub description: String, pub status: ProposalStatus, pub voting_method: String, pub voting_starts_at: Option>, pub voting_ends_at: Option>, pub created_at: DateTime, pub updated_at: DateTime, pub deliberation_phase: Option, pub inform_starts_at: Option>, pub inform_ends_at: Option>, pub discuss_starts_at: Option>, pub discuss_ends_at: Option>, pub min_read_time_seconds: Option, pub facilitator_id: Option, } #[derive(Debug, Clone, Serialize, Deserialize, FromRow)] #[allow(dead_code)] pub struct ProposalOption { pub id: Uuid, pub proposal_id: Uuid, pub label: String, pub description: Option, pub sort_order: i32, pub created_at: DateTime, } #[derive(Debug, Serialize)] pub struct ProposalWithOptions { #[serde(flatten)] pub proposal: Proposal, pub options: Vec, pub author_name: String, } #[derive(Debug, Serialize)] pub struct ProposalOptionWithVotes { pub id: Uuid, pub label: String, pub description: Option, pub vote_count: i64, } #[derive(Debug, Deserialize)] pub struct CreateProposal { pub title: String, pub description: String, pub options: Vec, }