user.go 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package models
  2. import (
  3. "time"
  4. )
  5. type User struct {
  6. ID uint `json:"id" gorm:"primarykey"`
  7. Username string `json:"username" gorm:"unique"`
  8. Password string `json:"password"`
  9. Role string `json:"role"`
  10. AvatarURL string `json:"avatar_url" gorm:"type:varchar(500)"` // 头像URL
  11. Nickname string `json:"nickname" gorm:"type:varchar(100)"` // 昵称
  12. Email string `json:"email" gorm:"type:varchar(255)"` // 邮箱
  13. CreatedAt time.Time `json:"created_at"` // 创建时间
  14. UpdatedAt time.Time `json:"updated_at"` // 更新时间
  15. }
  16. type Conversation struct {
  17. ID uint `json:"id" gorm:"primaryKey"`
  18. VisitorID uint `json:"visitor_id"`
  19. AgentID uint `json:"agent_id"`
  20. Status string `json:"status"`
  21. CreatedAt time.Time `json:"created_at"`
  22. UpdatedAt time.Time `json:"updated_at"`
  23. // 访客信息字段(自动收集)
  24. Website string `json:"website" gorm:"type:varchar(500)"` // 网站(当前页面URL)
  25. Referrer string `json:"referrer" gorm:"type:varchar(500)"` // 来源(referrer)
  26. Browser string `json:"browser" gorm:"type:varchar(100)"` // 浏览器信息
  27. OS string `json:"os" gorm:"type:varchar(100)"` // 操作系统
  28. Language string `json:"language" gorm:"type:varchar(50)"` // 语言
  29. IPAddress string `json:"ip_address" gorm:"type:varchar(50)"` // IP地址
  30. Location string `json:"location" gorm:"type:varchar(200)"` // 位置
  31. // 联系信息字段(客服手动添加)
  32. Email string `json:"email" gorm:"type:varchar(255)"` // 邮箱
  33. Phone string `json:"phone" gorm:"type:varchar(50)"` // 电话
  34. Notes string `json:"notes" gorm:"type:text"` // 备注
  35. // 在线状态
  36. LastSeenAt *time.Time `json:"last_seen_at"` // 最后活跃时间
  37. }
  38. type Message struct {
  39. ID uint `json:"id" gorm:"primarykey"`
  40. ConversationID uint `json:"conversation_id"`
  41. SenderID uint `json:"sender_id"`
  42. SenderIsAgent bool `json:"sender_is_agent"`
  43. Content string `json:"content" gorm:"type:text"`
  44. MessageType string `json:"message_type" gorm:"type:varchar(20);default:'user_message'"` // 消息类型:user_message, system_message
  45. IsRead bool `json:"is_read"`
  46. ReadAt *time.Time `json:"read_at"`
  47. CreatedAt time.Time `json:"created_at"`
  48. }