package models import ( "time" "github.com/google/uuid" ) // #[derive(Debug, Clone, sqlx::FromRow, Serialize, Deserialize)] // pub struct Channel { // pub id: Uuid, // #[sqlx(default)] // pub server_id: Option, // Option = nullable // #[sqlx(default)] // pub category_id: Option, // Option = nullable // #[sqlx(default)] // pub position: i32, // #[sqlx(rename = "type")] // pub channel_type: ChannelType, // pub name: Option, // Option = nullable // pub created_at: DateTime, // pub updated_at: DateTime, // } type ChannelType string const ( ChannelTypeText ChannelType = "text" ChannelTypeVoice ChannelType = "voice" ChannelTypeDM ChannelType = "dm" // Ajoutez vos autres types ici ) type Channel struct { ID uuid.UUID `gorm:"primaryKey" json:"id"` ServerID *uuid.UUID `gorm:"index;constraint:OnDelete:CASCADE;" json:"server_id,omitempty"` // Pointeur = nullable CategoryID *uuid.UUID `gorm:"index;constraint:OnDelete:SET NULL;" json:"category_id,omitempty"` // Pointeur = nullable Position int32 `gorm:"default:0" json:"position"` Type ChannelType `gorm:"not null;column:type" json:"type"` Name *string `gorm:"" json:"name,omitempty"` // Pointeur = nullable CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"` UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"` Users []*User `gorm:"many2many:channel_users" json:"users,omitempty"` // accès direct aux users UserLinks []ChannelUser `gorm:"foreignKey:ChannelID" json:"user_links,omitempty"` // accès aux lignes de jointure/métadonnées // Relations (optionnelles) Server *Server `gorm:"foreignKey:ServerID" json:"server,omitempty"` Category *Category `gorm:"foreignKey:CategoryID" json:"category,omitempty"` }