package models import ( "time" ) // Tenant 租户模型 type Tenant struct { ID uint `gorm:"primaryKey" json:"id"` Name string `gorm:"size:100;not null;unique" json:"name"` DisplayName string `gorm:"size:200" json:"display_name"` Description string `gorm:"type:text" json:"description"` Domain string `gorm:"size:100;unique" json:"domain"` Email string `gorm:"size:100;not null" json:"email"` Phone string `gorm:"size:20" json:"phone"` // 订阅信息 Plan string `gorm:"size:50;default:'free'" json:"plan"` Status string `gorm:"size:20;default:'active'" json:"status"` // active, suspended, cancelled ExpiresAt *time.Time `json:"expires_at"` // 资源配置 MaxUsers int `gorm:"default:10" json:"max_users"` MaxAgents int `gorm:"default:5" json:"max_agents"` MaxStorage int64 `gorm:"default:1073741824" json:"max_storage"` // 1GB in bytes MaxAPICalls int `gorm:"default:1000" json:"max_api_calls"` // 使用统计 UserCount int `gorm:"default:0" json:"user_count"` AgentCount int `gorm:"default:0" json:"agent_count"` StorageUsed int64 `gorm:"default:0" json:"storage_used"` APICallsUsed int `gorm:"default:0" json:"api_calls_used"` // 配置 Config JSONMap `gorm:"type:jsonb" json:"config"` // 时间戳 CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt *time.Time `gorm:"index" json:"deleted_at,omitempty"` } // JSONMap 用于存储JSON配置 type JSONMap map[string]interface{} // Scan 实现sql.Scanner接口 func (j *JSONMap) Scan(value interface{}) error { // 实现数据库扫描逻辑 return nil } // Value 实现driver.Valuer接口 func (j JSONMap) Value() (interface{}, error) { // 实现数据库值转换逻辑 return nil, nil }