chore(init): 初始化解忧商行项目并完成 Phase 0 基座
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package chat
|
||||
|
||||
import (
|
||||
"hfb_sys/backend/internal/model"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// DefaultSupportAdminID 导出默认客服选择逻辑,供其他业务模块建群时复用。
|
||||
func DefaultSupportAdminID(tx *gorm.DB) uint64 {
|
||||
return defaultSupportAdminID(tx)
|
||||
}
|
||||
|
||||
// SendSystemMessageForTx 在事务内发送系统文本消息。
|
||||
func SendSystemMessageForTx(tx *gorm.DB, conversationID uint64, content string) error {
|
||||
return sendSystemMessage(tx, conversationID, content)
|
||||
}
|
||||
|
||||
// SendImageMessageForTx 在事务内发送系统图片消息。
|
||||
func SendImageMessageForTx(tx *gorm.DB, conversationID uint64, content, imageURL string) error {
|
||||
if content == "" {
|
||||
content = "👇 请扫码联系客服"
|
||||
}
|
||||
message := model.ChatMessage{
|
||||
ConversationID: conversationID,
|
||||
SenderType: "system",
|
||||
SenderRole: "system",
|
||||
ContentType: "image",
|
||||
Content: content,
|
||||
AttachmentURLS: encodeStringList([]string{imageURL}),
|
||||
}
|
||||
if err := tx.Create(&message).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
return updateConversationLastMessage(tx, conversationID, &message)
|
||||
}
|
||||
Reference in New Issue
Block a user