优化sse

This commit is contained in:
yml2213
2026-05-29 11:09:15 +08:00
parent 2346f2e064
commit a334f1837d
3 changed files with 40 additions and 12 deletions
+6 -5
View File
@@ -191,14 +191,15 @@ func (r *Repository) EnsureSupportConversation(userID uint64) (*ConversationDTO,
Joins("JOIN chat_participants AS cp ON cp.conversation_id = c.id").
Where("c.type = ? AND cp.participant_type = ? AND cp.participant_id = ?", "general_support", "user", userID).
Order("c.id ASC").
First(&existing).Error
if err == nil {
Limit(1).
Find(&existing).Error
if err != nil {
return err
}
if existing.ID > 0 {
conversationID = existing.ID
return nil
}
if !errors.Is(err, gorm.ErrRecordNotFound) {
return err
}
now := time.Now()
conversation := model.ChatConversation{