package request import ( "netidhub-saas-be/utils/paginator" "github.com/google/uuid" ) // ======================================================================== // REQUEST STRUCTS - Updated for Multi-Client Hierarchy Support (camelCase) // ======================================================================== // CreateClientRequest for creating new client with hierarchy support type CreateClientRequest struct { Name string `json:"name" validate:"required"` Description *string `json:"description"` ClientType string `json:"clientType" validate:"required,oneof=parent_client sub_client standalone"` // Enum validation ParentClientId *uuid.UUID `json:"parentClientId"` // Optional: only for sub_client type // Resource limits MaxUsers *int `json:"maxUsers"` MaxStorage *int64 `json:"maxStorage"` // Custom settings (JSON string) Settings *string `json:"settings"` } // UpdateClientRequest for updating existing client type UpdateClientRequest struct { Name *string `json:"name"` Description *string `json:"description"` ClientType *string `json:"clientType" validate:"omitempty,oneof=parent_client sub_client standalone"` ParentClientId *uuid.UUID `json:"parentClientId"` // Resource limits MaxUsers *int `json:"maxUsers"` MaxStorage *int64 `json:"maxStorage"` // Custom settings Settings *string `json:"settings"` IsActive *bool `json:"isActive"` } // ClientsQueryRequest for filtering and pagination type ClientsQueryRequest struct { // Search filters Name *string `query:"name"` ClientType *string `query:"clientType" validate:"omitempty,oneof=parent_client sub_client standalone"` // Hierarchy filters ParentClientId *uuid.UUID `query:"parentClientId"` // Get children of specific parent IncludeSubClients *bool `query:"includeSubClients"` // Include all descendants OnlyParentClients *bool `query:"onlyParentClients"` // Only clients with children OnlyStandalone *bool `query:"onlyStandalone"` // Only standalone clients // Status filter IsActive *bool `query:"isActive"` Pagination *paginator.Pagination } // MoveClientRequest for moving client to different parent type MoveClientRequest struct { TargetParentId *uuid.UUID `json:"targetParentId"` // null = move to root (standalone) } // BulkCreateSubClientsRequest for creating multiple sub-clients at once type BulkCreateSubClientsRequest struct { ParentClientId uuid.UUID `json:"parentClientId" validate:"required"` SubClients []CreateSubClientDetail `json:"subClients" validate:"required,min=1,dive"` } type CreateSubClientDetail struct { Name string `json:"name" validate:"required"` Description *string `json:"description"` MaxUsers *int `json:"maxUsers"` MaxStorage *int64 `json:"maxStorage"` } // ClientHierarchyRequest for getting client tree structure type ClientHierarchyRequest struct { ClientId uuid.UUID `json:"clientId" validate:"required"` MaxDepth *int `json:"maxDepth"` // Limit recursion depth IncludeInactive *bool `json:"includeInactive"` } // ClientsQueryRequestContext for parsing query parameters from HTTP context type ClientsQueryRequestContext struct { Name string `query:"name"` ClientType string `query:"clientType"` ParentClientId string `query:"parentClientId"` IncludeSubClients string `query:"includeSubClients"` OnlyParentClients string `query:"onlyParentClients"` OnlyStandalone string `query:"onlyStandalone"` IsActive string `query:"isActive"` CreatedById string `query:"createdById"` } // ToParamRequest converts context to ClientsQueryRequest func (ctx *ClientsQueryRequestContext) ToParamRequest() ClientsQueryRequest { req := ClientsQueryRequest{} // Name filter if ctx.Name != "" { req.Name = &ctx.Name } // Client type filter if ctx.ClientType != "" { req.ClientType = &ctx.ClientType } // Parent client ID filter if ctx.ParentClientId != "" { if parentId, err := uuid.Parse(ctx.ParentClientId); err == nil { req.ParentClientId = &parentId } } // Boolean filters if ctx.IncludeSubClients != "" { includeSubClients := ctx.IncludeSubClients == "true" req.IncludeSubClients = &includeSubClients } if ctx.OnlyParentClients != "" { onlyParentClients := ctx.OnlyParentClients == "true" req.OnlyParentClients = &onlyParentClients } if ctx.OnlyStandalone != "" { onlyStandalone := ctx.OnlyStandalone == "true" req.OnlyStandalone = &onlyStandalone } if ctx.IsActive != "" { isActive := ctx.IsActive == "true" req.IsActive = &isActive } return req }