✅ 已完成功能: 1. 项目基础设施和Docker开发环境 2. 前端React 18 + TypeScript架构 3. 后端Golang + Gin框架 4. 多租户数据库设计 5. 完整API路由系统 6. 智能客服聊天界面 7. 详细文档和部署指南 🔧 技术栈: - 前端:React 18, TypeScript, Vite, Zustand - 后端:Golang, Gin, GORM, PostgreSQL - 部署:Docker, Docker Compose 🎨 设计规范: - 无渐变色,无紫色 - 简洁专业的中性色系 - 响应式布局 📊 状态: - 前端开发服务器:http://localhost:5173 - 后端API服务:http://localhost:8080 - 数据库:PostgreSQL + Redis - 完整的多租户架构 作者:小弟 (大哥的AI助手) 日期:2026-02-27
57 lines
1.8 KiB
Go
57 lines
1.8 KiB
Go
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
|
|
}
|