diff --git a/pkg/common/db/controller/conversation.go b/pkg/common/db/controller/conversation.go index 204bfd811..cbb440a7d 100644 --- a/pkg/common/db/controller/conversation.go +++ b/pkg/common/db/controller/conversation.go @@ -168,10 +168,11 @@ func (c *ConversationDataBase) SetUserConversations(ctx context.Context, ownerUs return err } if len(existConversations) > 0 { - log.ZDebug(ctx, "SetUserConversations", "existConversations", existConversations) - err = conversationTx.Update(ctx, conversations) - if err != nil { - return err + for _, conversation := range conversations { + err = conversationTx.Update(ctx, conversation) + if err != nil { + return err + } } } var existConversationIDs []string diff --git a/pkg/common/db/relation/conversation_model.go b/pkg/common/db/relation/conversation_model.go index 72c3710a9..d54161649 100644 --- a/pkg/common/db/relation/conversation_model.go +++ b/pkg/common/db/relation/conversation_model.go @@ -33,8 +33,8 @@ func (c *ConversationGorm) UpdateByMap(ctx context.Context, userIDList []string, return utils.Wrap(c.db(ctx).Where("owner_user_id IN (?) and conversation_id=?", userIDList, conversationID).Updates(args).Error, "") } -func (c *ConversationGorm) Update(ctx context.Context, conversations []*relation.ConversationModel) (err error) { - return utils.Wrap(c.db(ctx).Updates(&conversations).Error, "") +func (c *ConversationGorm) Update(ctx context.Context, conversation *relation.ConversationModel) (err error) { + return utils.Wrap(c.db(ctx).Updates(conversation).Error, "") } func (c *ConversationGorm) Find(ctx context.Context, ownerUserID string, conversationIDs []string) (conversations []*relation.ConversationModel, err error) { diff --git a/pkg/common/db/table/relation/conversation.go b/pkg/common/db/table/relation/conversation.go index 6971d06f3..b2cbde6a1 100644 --- a/pkg/common/db/table/relation/conversation.go +++ b/pkg/common/db/table/relation/conversation.go @@ -33,7 +33,7 @@ type ConversationModelInterface interface { Create(ctx context.Context, conversations []*ConversationModel) (err error) Delete(ctx context.Context, groupIDs []string) (err error) UpdateByMap(ctx context.Context, userIDs []string, conversationID string, args map[string]interface{}) (err error) - Update(ctx context.Context, conversations []*ConversationModel) (err error) + Update(ctx context.Context, conversation *ConversationModel) (err error) Find(ctx context.Context, ownerUserID string, conversationIDs []string) (conversations []*ConversationModel, err error) FindUserID(ctx context.Context, userIDs []string, conversationID string) ([]string, error) FindUserIDAllConversationID(ctx context.Context, userID string) ([]string, error)