修改聊天和登录信息的数据库结构

This commit is contained in:
flswld
2023-02-12 16:08:56 +08:00
parent 15199d31e8
commit 36a150c9bb
17 changed files with 171 additions and 118 deletions

View File

@@ -279,3 +279,24 @@ func (d *Dao) QueryChatMsgListByUid(uid uint32) ([]*model.ChatMsg, error) {
}
return result, nil
}
func (d *Dao) ReadAndUpdateChatMsgByUid(uid uint32, targetUid uint32) error {
db := d.db.Collection("chat_msg")
_, err := db.UpdateOne(
context.TODO(),
bson.D{{"ToUid", uid}, {"Uid", targetUid}},
bson.D{{"$set", bson.D{{"IsRead", true}}}},
)
if err != nil {
return err
}
_, err = db.UpdateOne(
context.TODO(),
bson.D{{"Uid", uid}, {"ToUid", targetUid}},
bson.D{{"$set", bson.D{{"IsRead", true}}}},
)
if err != nil {
return err
}
return nil
}