kontenhumas-be/app/database/entity/clients.entity.go

27 lines
1.2 KiB
Go

package entity
import (
"github.com/google/uuid"
"time"
)
type Clients struct {
ID uuid.UUID `json:"id" gorm:"primaryKey;type:UUID"`
Name string `json:"name" gorm:"type:varchar"`
Description *string `json:"description" gorm:"type:text"`
ClientType string `json:"client_type" gorm:"type:varchar;default:'sub_client'"` // 'parent_client', 'sub_client', 'standalone'
ParentClientId *uuid.UUID `json:"parent_client_id" gorm:"type:UUID;index"`
ParentClient *Clients `json:"parent_client,omitempty" gorm:"foreignKey:ParentClientId;references:ID"`
SubClients []Clients `json:"sub_clients,omitempty" gorm:"foreignKey:ParentClientId;references:ID"`
// Metadata
Settings *string `json:"settings" gorm:"type:jsonb"` // JSON for custom settings
MaxUsers *int `json:"max_users" gorm:"type:int4"` // Limit for sub clients
MaxStorage *int64 `json:"max_storage" gorm:"type:int8"` // In bytes
CreatedById *uint `json:"created_by_id" gorm:"type:int4"`
IsActive *bool `json:"is_active" gorm:"type:bool;default:true"`
CreatedAt time.Time `json:"created_at" gorm:"default:now()"`
UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"`
}