2025-09-28 01:53:09 +00:00
|
|
|
package response
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"time"
|
2025-09-30 13:34:56 +00:00
|
|
|
|
|
|
|
|
"github.com/google/uuid"
|
2025-09-28 01:53:09 +00:00
|
|
|
)
|
|
|
|
|
|
2025-09-30 13:34:56 +00:00
|
|
|
// ========================================================================
|
|
|
|
|
// RESPONSE STRUCTS - Updated for Multi-Client Hierarchy Support (camelCase)
|
|
|
|
|
// ========================================================================
|
|
|
|
|
|
|
|
|
|
// ClientResponse for single client with hierarchy info
|
2025-09-28 01:53:09 +00:00
|
|
|
type ClientsResponse struct {
|
2025-09-30 13:34:56 +00:00
|
|
|
ID uuid.UUID `json:"id"`
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
Description *string `json:"description"`
|
|
|
|
|
ClientType string `json:"clientType"`
|
|
|
|
|
ParentClientId *uuid.UUID `json:"parentClientId"`
|
|
|
|
|
|
|
|
|
|
// Parent info (if sub_client)
|
|
|
|
|
ParentClient *ParentClientInfo `json:"parentClient,omitempty"`
|
|
|
|
|
|
|
|
|
|
// Children info (if parent_client)
|
|
|
|
|
SubClients []SubClientInfo `json:"subClients,omitempty"`
|
|
|
|
|
SubClientCount int `json:"subClientCount"`
|
|
|
|
|
|
|
|
|
|
// Resource limits & usage
|
|
|
|
|
MaxUsers *int `json:"maxUsers"`
|
|
|
|
|
MaxStorage *int64 `json:"maxStorage"`
|
|
|
|
|
CurrentUsers int `json:"currentUsers"` // Count of active users
|
|
|
|
|
CurrentStorage *int64 `json:"currentStorage"` // Current storage usage (if tracked)
|
|
|
|
|
|
|
|
|
|
// Settings
|
|
|
|
|
Settings *string `json:"settings"`
|
|
|
|
|
|
|
|
|
|
// Metadata
|
|
|
|
|
CreatedById *uint `json:"createdById"`
|
|
|
|
|
CreatedBy *UserInfo `json:"createdBy,omitempty"`
|
|
|
|
|
IsActive *bool `json:"isActive"`
|
2025-09-28 01:53:09 +00:00
|
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
|
|
|
UpdatedAt time.Time `json:"updatedAt"`
|
|
|
|
|
}
|
2025-09-30 13:34:56 +00:00
|
|
|
|
|
|
|
|
// ParentClientInfo minimal parent info
|
|
|
|
|
type ParentClientInfo struct {
|
|
|
|
|
ID uuid.UUID `json:"id"`
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
ClientType string `json:"clientType"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SubClientInfo minimal child info
|
|
|
|
|
type SubClientInfo struct {
|
|
|
|
|
ID uuid.UUID `json:"id"`
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
ClientType string `json:"clientType"`
|
|
|
|
|
CurrentUsers int `json:"currentUsers"`
|
|
|
|
|
IsActive *bool `json:"isActive"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UserInfo minimal user info
|
|
|
|
|
type UserInfo struct {
|
|
|
|
|
ID uint `json:"id"`
|
|
|
|
|
Username string `json:"username"`
|
|
|
|
|
Fullname string `json:"fullname"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ClientHierarchyResponse full tree structure
|
|
|
|
|
type ClientHierarchyResponse struct {
|
|
|
|
|
ID uuid.UUID `json:"id"`
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
Description *string `json:"description"`
|
|
|
|
|
ClientType string `json:"clientType"`
|
|
|
|
|
Level int `json:"level"` // Depth in tree (0 = root)
|
|
|
|
|
Path []string `json:"path"` // Breadcrumb path
|
|
|
|
|
ParentClientId *uuid.UUID `json:"parentClientId"`
|
|
|
|
|
SubClients []ClientHierarchyResponse `json:"subClients,omitempty"`
|
|
|
|
|
CurrentUsers int `json:"currentUsers"`
|
|
|
|
|
IsActive *bool `json:"isActive"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ClientStatsResponse statistics for a client
|
|
|
|
|
type ClientStatsResponse struct {
|
|
|
|
|
ClientId uuid.UUID `json:"clientId"`
|
|
|
|
|
ClientName string `json:"clientName"`
|
|
|
|
|
|
|
|
|
|
// User stats
|
|
|
|
|
TotalUsers int `json:"totalUsers"`
|
|
|
|
|
ActiveUsers int `json:"activeUsers"`
|
|
|
|
|
InactiveUsers int `json:"inactiveUsers"`
|
|
|
|
|
|
|
|
|
|
// Content stats
|
|
|
|
|
TotalArticles int `json:"totalArticles"`
|
|
|
|
|
PublishedArticles int `json:"publishedArticles"`
|
|
|
|
|
DraftArticles int `json:"draftArticles"`
|
|
|
|
|
|
|
|
|
|
// Storage stats
|
|
|
|
|
StorageUsed *int64 `json:"storageUsed"`
|
|
|
|
|
StorageLimit *int64 `json:"storageLimit"`
|
|
|
|
|
StoragePercent *float64 `json:"storagePercent"`
|
|
|
|
|
|
|
|
|
|
// Hierarchy stats
|
|
|
|
|
IsParent bool `json:"isParent"`
|
|
|
|
|
SubClientCount int `json:"subClientCount"`
|
|
|
|
|
TotalDescendants int `json:"totalDescendants"` // All nested sub-clients
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ClientListResponse for list endpoint
|
|
|
|
|
type ClientListResponse struct {
|
|
|
|
|
ID uuid.UUID `json:"id"`
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
ClientType string `json:"clientType"`
|
|
|
|
|
ParentClientId *uuid.UUID `json:"parentClientId"`
|
|
|
|
|
ParentName *string `json:"parentName,omitempty"`
|
|
|
|
|
SubClientCount int `json:"subClientCount"`
|
|
|
|
|
CurrentUsers int `json:"currentUsers"`
|
|
|
|
|
IsActive *bool `json:"isActive"`
|
|
|
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ClientAccessResponse for user's accessible clients
|
|
|
|
|
type ClientAccessResponse struct {
|
|
|
|
|
// User info
|
|
|
|
|
UserId uint `json:"userId"`
|
|
|
|
|
Username string `json:"username"`
|
|
|
|
|
|
|
|
|
|
// Access summary
|
|
|
|
|
IsSuperAdmin bool `json:"isSuperAdmin"`
|
|
|
|
|
PrimaryClientId *uuid.UUID `json:"primaryClientId"`
|
|
|
|
|
TotalAccessible int `json:"totalAccessibleClients"`
|
|
|
|
|
|
|
|
|
|
// Accessible clients
|
|
|
|
|
Clients []AccessibleClientInfo `json:"clients"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type AccessibleClientInfo struct {
|
|
|
|
|
ClientId uuid.UUID `json:"clientId"`
|
|
|
|
|
ClientName string `json:"clientName"`
|
|
|
|
|
ClientType string `json:"clientType"`
|
|
|
|
|
AccessType string `json:"accessType"` // read, write, admin, owner
|
|
|
|
|
CanManage bool `json:"canManage"`
|
|
|
|
|
CanDelegate bool `json:"canDelegate"`
|
|
|
|
|
IncludeSubClients bool `json:"includeSubClients"`
|
|
|
|
|
IsPrimaryClient bool `json:"isPrimaryClient"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// BulkOperationResponse for bulk operations
|
|
|
|
|
type BulkOperationResponse struct {
|
|
|
|
|
TotalRequested int `json:"totalRequested"`
|
|
|
|
|
Successful int `json:"successful"`
|
|
|
|
|
Failed int `json:"failed"`
|
|
|
|
|
Results []BulkOperationResult `json:"results"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type BulkOperationResult struct {
|
|
|
|
|
Index int `json:"index"`
|
|
|
|
|
ClientId *uuid.UUID `json:"clientId,omitempty"`
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
Success bool `json:"success"`
|
|
|
|
|
Error *string `json:"error,omitempty"`
|
|
|
|
|
}
|