koprogo_api/application/dto/
board_member_dto.rs

1use serde::{Deserialize, Serialize};
2use validator::Validate;
3
4/// DTO pour créer un nouveau membre du conseil
5/// Note: board members must be property owners (Owner), not platform users
6#[derive(Debug, Serialize, Deserialize, Validate, Clone)]
7pub struct CreateBoardMemberDto {
8    pub owner_id: String, // UUID as string - ID du copropriétaire (Owner)
9
10    pub building_id: String, // UUID as string
11
12    #[validate(length(min = 1, message = "Position cannot be empty"))]
13    pub position: String, // "president", "treasurer", or "member"
14
15    pub mandate_start: String, // ISO 8601 datetime string
16
17    pub mandate_end: String, // ISO 8601 datetime string
18
19    pub elected_by_meeting_id: String, // UUID as string - ID de l'AG qui élit
20}
21
22/// DTO pour renouveler un mandat existant
23#[derive(Debug, Serialize, Deserialize, Validate, Clone)]
24pub struct RenewMandateDto {
25    pub new_elected_by_meeting_id: String, // UUID de la nouvelle AG qui renouvelle
26}
27
28/// DTO pour la réponse API d'un membre du conseil
29#[derive(Debug, Serialize, Deserialize, Clone)]
30pub struct BoardMemberResponseDto {
31    pub id: String,
32    pub owner_id: String, // ID du copropriétaire (Owner)
33    pub building_id: String,
34    pub position: String,
35    pub mandate_start: String,
36    pub mandate_end: String,
37    pub elected_by_meeting_id: String,
38    pub is_active: bool,     // Calculé: mandat actuellement actif?
39    pub days_remaining: i64, // Calculé: jours restants dans le mandat
40    pub expires_soon: bool,  // Calculé: expire dans < 60 jours?
41    pub created_at: String,
42    pub updated_at: String,
43}
44
45/// DTO pour obtenir des statistiques sur le conseil
46#[derive(Debug, Serialize, Deserialize, Clone)]
47pub struct BoardStatsDto {
48    pub building_id: String,
49    pub total_members: i64,
50    pub active_members: i64,
51    pub expiring_soon: i64, // Nombre de mandats expirant dans < 60 jours
52    pub has_president: bool,
53    pub has_treasurer: bool,
54}