types.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. package service
  2. import "time"
  3. // BroadcastHub 描述 WebSocket Hub 的广播能力。
  4. type BroadcastHub interface {
  5. BroadcastMessage(conversationID uint, messageType string, data interface{})
  6. }
  7. // InitConversationInput 对话初始化需要的输入数据。
  8. type InitConversationInput struct {
  9. VisitorID uint
  10. Website string
  11. Referrer string
  12. Browser string
  13. OS string
  14. Language string
  15. IPAddress string
  16. }
  17. // InitConversationResult 对话初始化后的返回结果。
  18. type InitConversationResult struct {
  19. ConversationID uint
  20. Status string
  21. }
  22. // UpdateConversationContactInput 更新访客联系信息时需要的参数。
  23. type UpdateConversationContactInput struct {
  24. ConversationID uint
  25. Email *string
  26. Phone *string
  27. Notes *string
  28. }
  29. // ConversationSummary 用于会话列表展示的概要信息。
  30. type ConversationSummary struct {
  31. ID uint
  32. VisitorID uint
  33. AgentID uint
  34. Status string
  35. CreatedAt time.Time
  36. UpdatedAt time.Time
  37. LastMessage *LastMessageSummary
  38. UnreadCount int64
  39. LastSeenAt *time.Time // 最后活跃时间,用于判断在线状态
  40. }
  41. // LastMessageSummary 会话最后一条消息的摘要信息。
  42. type LastMessageSummary struct {
  43. ID uint
  44. Content string
  45. SenderIsAgent bool
  46. MessageType string
  47. IsRead bool
  48. ReadAt *time.Time
  49. CreatedAt time.Time
  50. }
  51. // ConversationDetail 在会话概要基础上附加访客信息。
  52. type ConversationDetail struct {
  53. ConversationSummary
  54. Website string
  55. Referrer string
  56. Browser string
  57. OS string
  58. Language string
  59. IPAddress string
  60. Location string
  61. Email string
  62. Phone string
  63. Notes string
  64. LastSeen *time.Time
  65. }
  66. // CreateMessageInput 创建消息时需要的参数。
  67. type CreateMessageInput struct {
  68. ConversationID uint
  69. Content string
  70. SenderID uint
  71. SenderIsAgent bool
  72. }
  73. // CreateAgentInput 创建客服或管理员账号需要的参数。
  74. type CreateAgentInput struct {
  75. Username string
  76. Password string
  77. Role string
  78. }
  79. // MarkMessagesReadResult 消息标记已读后的返回信息。
  80. type MarkMessagesReadResult struct {
  81. ConversationID uint
  82. MessageIDs []uint
  83. UnreadCount int64
  84. ReadAt time.Time
  85. }
  86. // UpdateProfileInput 更新个人资料时需要的参数。
  87. type UpdateProfileInput struct {
  88. UserID uint
  89. Nickname *string
  90. Email *string
  91. }
  92. // ProfileResult 个人资料信息。
  93. type ProfileResult struct {
  94. ID uint `json:"id"`
  95. Username string `json:"username"`
  96. Role string `json:"role"`
  97. AvatarURL string `json:"avatar_url"`
  98. Nickname string `json:"nickname"`
  99. Email string `json:"email"`
  100. }