You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Open-IM-Server/internal/msg_transfer/logic/db.go

29 lines
989 B

package logic
import (
"Open_IM/pkg/common/db"
3 years ago
"Open_IM/pkg/common/log"
pbMsg "Open_IM/pkg/proto/chat"
3 years ago
"Open_IM/pkg/utils"
)
func saveUserChat(uid string, msg *pbMsg.MsgDataToMQ) error {
3 years ago
time := utils.GetCurrentTimestampByMill()
seq, err := db.DB.IncrUserSeq(uid)
if err != nil {
log.NewError(msg.OperationID, "data insert to redis err", err.Error(), msg.String())
return err
}
msg.MsgData.Seq = uint32(seq)
pbSaveData := pbMsg.MsgDataToDB{}
pbSaveData.MsgData = msg.MsgData
3 years ago
log.NewInfo(msg.OperationID, "IncrUserSeq cost time", utils.GetCurrentTimestampByMill()-time)
3 years ago
return db.DB.SaveUserChatMongo2(uid, pbSaveData.MsgData.SendTime, &pbSaveData)
// return db.DB.SaveUserChatMongo2(uid, pbSaveData.MsgData.SendTime, &pbSaveData)
}
3 years ago
3 years ago
func saveUserChatList(userID string, msgList []*pbMsg.MsgDataToMQ, operationID string) error {
log.Info(operationID, utils.GetSelfFuncName(), "args ", userID, len(msgList))
return db.DB.BatchInsertChat(userID, msgList, operationID)
3 years ago
}