mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-01 07:35:58 +08:00
Merge branch 'dtm' into v2.3.0release
# Conflicts: # internal/rpc/group/group.go
This commit is contained in:
@@ -19,10 +19,6 @@ import (
|
||||
)
|
||||
|
||||
func InsertMessageToChatLog(msg pbMsg.MsgDataToMQ) error {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
chatLog := new(db.ChatLog)
|
||||
copier.Copy(chatLog, msg.MsgData)
|
||||
switch msg.MsgData.SessionType {
|
||||
@@ -47,5 +43,5 @@ func InsertMessageToChatLog(msg pbMsg.MsgDataToMQ) error {
|
||||
chatLog.CreateTime = utils.UnixMillSecondToTime(msg.MsgData.CreateTime)
|
||||
chatLog.SendTime = utils.UnixMillSecondToTime(msg.MsgData.SendTime)
|
||||
log.NewDebug("test", "this is ", chatLog)
|
||||
return dbConn.Table("chat_logs").Create(chatLog).Error
|
||||
return db.DB.MysqlDB.DefaultGormDB().Table("chat_logs").Create(chatLog).Error
|
||||
}
|
||||
|
||||
@@ -2,9 +2,7 @@ package im_mysql_msg_model
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/db"
|
||||
"hash/crc32"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func getHashMsgDBAddr(userID string) string {
|
||||
@@ -16,21 +14,3 @@ func getHashMsgTableIndex(userID string) int {
|
||||
hCode := crc32.ChecksumIEEE([]byte(userID))
|
||||
return int(hCode % uint32(config.Config.Mysql.DBMsgTableNum))
|
||||
}
|
||||
|
||||
func QueryUserMsgID(userID string) ([]string, error) {
|
||||
dbAddress, dbTableIndex := getHashMsgDBAddr(userID), getHashMsgTableIndex(userID)
|
||||
dbTableName := "receive" + strconv.Itoa(dbTableIndex)
|
||||
|
||||
dbConn, _ := db.DB.MysqlDB.GormDB(dbAddress, config.Config.Mysql.DBTableName)
|
||||
|
||||
var msgID string
|
||||
var msgIDList []string
|
||||
rows, _ := dbConn.Raw("select msg_id from ? where user_id = ?", dbTableName, userID).Rows()
|
||||
defer rows.Close()
|
||||
for rows.Next() {
|
||||
rows.Scan(&msgID)
|
||||
msgIDList = append(msgIDList, msgID)
|
||||
}
|
||||
|
||||
return msgIDList, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user