refactor: 将客服后端重构为宿主可嵌入模块
- 注入数据库、运行时配置、统一响应、文件存储和平台 AI 能力,补充业务读写工具与客户快捷操作契约。 - 移除模块内重复的组织、客户、工单、标签、技能、旧工作流、MCP 和迁移实现,将身份权限与业务主体交由宿主管理。 - 使用 libSQL 重构向量存储,并完善图片消息、访客身份、排队调度、企业微信和支持聊天页面。 - 统一 HTTP、DTO 与 WebSocket 的 snake_case 协议,补齐模块初始化、业务动作和公共载荷等回归测试。
This commit is contained in:
@@ -16,47 +16,6 @@ import (
|
||||
"gorm.io/gorm/schema"
|
||||
)
|
||||
|
||||
func TestTicketAssignedInAppNotification(t *testing.T) {
|
||||
setupNotificationEventHandlerTestDB(t)
|
||||
|
||||
ticket := &models.Ticket{
|
||||
TicketNo: "TK202604280001",
|
||||
Title: "退款处理",
|
||||
Source: enums.TicketSourceManual,
|
||||
Status: enums.TicketStatusPending,
|
||||
CurrentAssigneeID: 11,
|
||||
AuditFields: models.AuditFields{
|
||||
CreatedAt: time.Now(),
|
||||
UpdatedAt: time.Now(),
|
||||
},
|
||||
}
|
||||
if err := repositories.TicketRepository.Create(sqls.DB(), ticket); err != nil {
|
||||
t.Fatalf("create ticket error = %v", err)
|
||||
}
|
||||
|
||||
if err := handleTicketAssignedInAppNotification(context.Background(), events.TicketAssignedEvent{
|
||||
TicketID: ticket.ID,
|
||||
FromUserID: 0,
|
||||
ToUserID: 11,
|
||||
OperatorID: 1,
|
||||
Reason: "需要人工跟进",
|
||||
}); err != nil {
|
||||
t.Fatalf("handler error = %v", err)
|
||||
}
|
||||
|
||||
list := repositories.NotificationRepository.Find(sqls.DB(), sqls.NewCnd().Eq("recipient_user_id", 11))
|
||||
if len(list) != 1 {
|
||||
t.Fatalf("expected 1 notification, got %d", len(list))
|
||||
}
|
||||
got := list[0]
|
||||
if got.NotificationType != "ticket_assigned" || got.BizType != "ticket" || got.BizID != ticket.ID {
|
||||
t.Fatalf("unexpected notification: %+v", got)
|
||||
}
|
||||
if got.ActionURL != "/dashboard/tickets?ticketId=1" {
|
||||
t.Fatalf("unexpected action url: %q", got.ActionURL)
|
||||
}
|
||||
}
|
||||
|
||||
func TestConversationAssignedInAppNotification(t *testing.T) {
|
||||
setupNotificationEventHandlerTestDB(t)
|
||||
|
||||
@@ -92,7 +51,7 @@ func TestConversationAssignedInAppNotification(t *testing.T) {
|
||||
if got.NotificationType != "conversation_assigned" || got.BizType != "conversation" || got.BizID != conversation.ID {
|
||||
t.Fatalf("unexpected notification: %+v", got)
|
||||
}
|
||||
if got.ActionURL != "/dashboard/conversations?conversationId=1" {
|
||||
if got.ActionURL != "/dashboard/conversations?conversation_id=1" {
|
||||
t.Fatalf("unexpected action url: %q", got.ActionURL)
|
||||
}
|
||||
}
|
||||
@@ -115,7 +74,7 @@ func setupNotificationEventHandlerTestDB(t *testing.T) *gorm.DB {
|
||||
_ = sqlDB.Close()
|
||||
}
|
||||
})
|
||||
if err := db.AutoMigrate(&models.Notification{}, &models.Ticket{}, &models.Conversation{}); err != nil {
|
||||
if err := db.AutoMigrate(&models.Notification{}, &models.Conversation{}); err != nil {
|
||||
t.Fatalf("auto migrate error = %v", err)
|
||||
}
|
||||
sqls.SetDB(db)
|
||||
|
||||
Reference in New Issue
Block a user