feat: 智能客服系统基础架构完成
✅ 已完成功能: 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
This commit is contained in:
74
backend/internal/models/user.go
Normal file
74
backend/internal/models/user.go
Normal file
@@ -0,0 +1,74 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// User 用户模型(多租户共享表,通过tenant_id区分)
|
||||
type User struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
TenantID uint `gorm:"not null;index" json:"tenant_id"`
|
||||
Username string `gorm:"size:50;not null;index" json:"username"`
|
||||
Email string `gorm:"size:100;not null;uniqueIndex:idx_email_tenant" json:"email"`
|
||||
Password string `gorm:"size:255;not null" json:"-"`
|
||||
Phone string `gorm:"size:20" json:"phone"`
|
||||
|
||||
// 个人信息
|
||||
FullName string `gorm:"size:100" json:"full_name"`
|
||||
Avatar string `gorm:"size:255" json:"avatar"`
|
||||
Bio string `gorm:"type:text" json:"bio"`
|
||||
|
||||
// 角色和权限
|
||||
Role string `gorm:"size:20;default:'user'" json:"role"` // super_admin, admin, agent, user
|
||||
Status string `gorm:"size:20;default:'active'" json:"status"` // active, inactive, banned
|
||||
IsVerified bool `gorm:"default:false" json:"is_verified"`
|
||||
|
||||
// 最后活动
|
||||
LastLoginAt *time.Time `json:"last_login_at"`
|
||||
LastIP string `gorm:"size:45" json:"last_ip"`
|
||||
|
||||
// 配置
|
||||
Preferences JSONMap `gorm:"type:jsonb" json:"preferences"`
|
||||
|
||||
// 时间戳
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt *time.Time `gorm:"index" json:"deleted_at,omitempty"`
|
||||
|
||||
// 关联
|
||||
Tenant Tenant `gorm:"foreignKey:TenantID" json:"tenant,omitempty"`
|
||||
}
|
||||
|
||||
// Agent 客服坐席模型
|
||||
type Agent struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
TenantID uint `gorm:"not null;index" json:"tenant_id"`
|
||||
UserID uint `gorm:"not null;uniqueIndex" json:"user_id"`
|
||||
|
||||
// 坐席信息
|
||||
AgentID string `gorm:"size:50;not null;unique" json:"agent_id"` // 坐席工号
|
||||
Department string `gorm:"size:100" json:"department"`
|
||||
Title string `gorm:"size:100" json:"title"`
|
||||
Skills []string `gorm:"type:jsonb" json:"skills"`
|
||||
|
||||
// 工作状态
|
||||
Status string `gorm:"size:20;default:'offline'" json:"status"` // online, offline, busy, away
|
||||
MaxChats int `gorm:"default:5" json:"max_chats"` // 最大同时聊天数
|
||||
CurrentChats int `gorm:"default:0" json:"current_chats"`
|
||||
|
||||
// 绩效统计
|
||||
TotalChats int `gorm:"default:0" json:"total_chats"`
|
||||
AvgRating float64 `gorm:"default:0" json:"avg_rating"`
|
||||
ResponseTimeAvg int `gorm:"default:0" json:"response_time_avg"` // 平均响应时间(秒)
|
||||
|
||||
// 工作时间
|
||||
WorkSchedule JSONMap `gorm:"type:jsonb" json:"work_schedule"`
|
||||
|
||||
// 时间戳
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
|
||||
// 关联
|
||||
User User `gorm:"foreignKey:UserID" json:"user"`
|
||||
Tenant Tenant `gorm:"foreignKey:TenantID" json:"tenant,omitempty"`
|
||||
}
|
||||
Reference in New Issue
Block a user