package models import "time" // APIResponse represents a standard API response type APIResponse struct { Success bool `json:"success"` Message string `json:"message,omitempty"` Data interface{} `json:"data,omitempty"` Error string `json:"error,omitempty"` } // LoginRequest represents a login request type LoginRequest struct { Email string `json:"email" binding:"required"` Password string `json:"password" binding:"required"` } // LoginResponse represents a login response type LoginResponse struct { Token string `json:"token"` User User `json:"user"` } const ( AppStatusBuilding = "building" AppStatusDeploying = "deploying" AppStatusReady = "ready" AppStatusFailed = "failed" ) type App struct { ID int `json:"id" db:"id"` UserID int `json:"user_id" db:"user_id"` Name string `json:"name" db:"name" validate:"required"` Description string `json:"description" db:"description"` Components []int `json:"components" db:"components"` // Component IDs Status string `json:"status" db:"status"` // e.g., AppStatusBuilding, AppStatusReady, AppStatusFailed PreviewID int `json:"preview_id" db:"preview_id"` // Current preview ID PreviewURL string `json:"preview_url" db:"preview_url"` // Current preview URL CurrentImageTag string `json:"current_image_tag" db:"current_image_tag"` // Added CurrentImageURI string `json:"current_image_uri" db:"current_image_uri"` // Added ErrorMsg string `json:"error_msg" db:"error_msg"` CreatedAt string `json:"created_at" db:"created_at"` UpdatedAt string `json:"updated_at" db:"updated_at"` } // Component represents a deployable component type Component struct { ID int `json:"id"` UserID int `json:"user_id"` Name string `json:"name"` Description string `json:"description"` Type string `json:"type"` // web, api, database, etc. Status string `json:"status"` // active, inactive, deploying, etc. ErrorMsg string `json:"error_msg" db:"error_msg"` // Error message if validation fails Config string `json:"config"` // JSON configuration Repository string `json:"repository"` // URL to the git repository Branch string `json:"branch"` CurrentImageTag string `json:"current_image_tag" db:"current_image_tag"` // Current built image tag CurrentImageURI string `json:"current_image_uri" db:"current_image_uri"` // Current built image full URI CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` } // Deployment represents a deployment instance type Deployment struct { ID int `json:"id"` AppId int `json:"app_id"` ClientID int `json:"client_id"` Name string `json:"name"` Description string `json:"description"` Environment string `json:"environment"` // dev, staging, prod Status string `json:"status"` // pending, running, stopped, failed URL string `json:"url"` Config string `json:"config"` // JSON deployment configuration DeployedAt time.Time `json:"deployed_at"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` } // Provider represents a cloud provider type Provider struct { ID int `json:"id"` Name string `json:"name"` Type string `json:"type"` // aws, digitalocean, ovh, etc. Config string `json:"config"` Active bool `json:"active"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` } // TicketStatus defines the possible statuses for a ticket. const ( TicketStatusOpen = "open" TicketStatusInProgress = "in_progress" TicketStatusResolved = "resolved" TicketStatusClosed = "closed" ) // TicketPriority defines the possible priorities for a ticket. const ( TicketPriorityLow = "low" TicketPriorityMedium = "medium" TicketPriorityHigh = "high" TicketPriorityCritical = "critical" ) // Ticket represents a support ticket type Ticket struct { ID int `json:"id"` ClientID int `json:"client_id"` // Link to Client who reported it UserID *int `json:"user_id,omitempty"` // Link to User who reported it (optional) AssignedTo *int `json:"assigned_to,omitempty"` // Link to User it is assigned to (optional) Title string `json:"title"` Description string `json:"description"` Status string `json:"status"` // e.g., open, in_progress, resolved, closed Priority string `json:"priority"` // e.g., low, medium, high, critical CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` ResolvedAt *time.Time `json:"resolved_at,omitempty"` // When the ticket was resolved } // TicketComment represents a comment on a support ticket type TicketComment struct { ID int `json:"id"` TicketID int `json:"ticket_id"` // Link to the parent Ticket UserID int `json:"user_id"` // Link to User who made the comment Content string `json:"content"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` } // Role constants for User const ( RoleAdmin = "admin" RoleUser = "user" RoleEditor = "editor" // Example additional role ) // User represents a user in the system type User struct { ID int `json:"id" db:"id"` Email string `json:"email" db:"email" validate:"required,email"` Password string `json:"-" db:"password"` // Never include password in JSON responses Name string `json:"name" db:"name" validate:"required"` Role string `json:"role" db:"role" validate:"required,oneof=user admin editor"` Active bool `json:"active" db:"active"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` } // Client represents a client in the system type Client struct { ID int `json:"id" db:"id"` Name string `json:"name" db:"name" validate:"required"` Description string `json:"description" db:"description"` ContactInfo string `json:"contact_info" db:"contact_info"` Active bool `json:"active" db:"active"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` } // PreviewStatus defines the possible statuses for a preview. const ( PreviewStatusBuilding = "building" PreviewStatusDeploying = "deploying" PreviewStatusRunning = "running" PreviewStatusFailed = "failed" PreviewStatusStopped = "stopped" ) type Preview struct { ID int `json:"id" db:"id"` AppID int `json:"app_id" db:"app_id"` Status string `json:"status" db:"status"` // e.g., PreviewStatusBuilding, PreviewStatusRunning URL string `json:"url" db:"url"` // Preview URL (http://vps-ip) VPSID string `json:"vps_id" db:"vps_id"` // OVH VPS ID IPAddress string `json:"ip_address" db:"ip_address"` // VPS IP address ErrorMsg string `json:"error_msg" db:"error_msg"` BuildLogs string `json:"build_logs" db:"build_logs"` DeployLogs string `json:"deploy_logs" db:"deploy_logs"` ExpiresAt string `json:"expires_at" db:"expires_at"` // Auto-cleanup after X hours CreatedAt string `json:"created_at" db:"created_at"` UpdatedAt string `json:"updated_at" db:"updated_at"` }