This commit is contained in:
wangchuxiao
2022-08-30 01:38:23 +08:00
parent da9918b655
commit 8d4e5ad3f1
23 changed files with 548 additions and 2351 deletions
+6 -6
View File
@@ -227,17 +227,17 @@ type Black struct {
type ChatLog struct {
ServerMsgID string `gorm:"column:server_msg_id;primary_key;type:char(64)" json:"serverMsgID"`
ClientMsgID string `gorm:"column:client_msg_id;type:char(64)" json:"clientMsgID"`
SendID string `gorm:"column:send_id;type:char(64)" json:"sendID"`
RecvID string `gorm:"column:recv_id;type:char(64)" json:"recvID"`
SendID string `gorm:"column:send_id;type:char(64);index:search" json:"sendID"`
RecvID string `gorm:"column:recv_id;type:char(64);index:search" json:"recvID"`
SenderPlatformID int32 `gorm:"column:sender_platform_id" json:"senderPlatformID"`
SenderNickname string `gorm:"column:sender_nick_name;type:varchar(255)" json:"senderNickname"`
SenderFaceURL string `gorm:"column:sender_face_url;type:varchar(255)" json:"senderFaceURL"`
SessionType int32 `gorm:"column:session_type" json:"sessionType"`
SessionType int32 `gorm:"column:session_type;;index:search" json:"sessionType"`
MsgFrom int32 `gorm:"column:msg_from" json:"msgFrom"`
ContentType int32 `gorm:"column:content_type" json:"contentType"`
Content string `gorm:"column:content;type:varchar(3000)" json:"content"`
ContentType int32 `gorm:"column:content_type;index:search" json:"contentType"`
Content string `gorm:"column:content;type:varchar(3000);index:search" json:"content"`
Status int32 `gorm:"column:status" json:"status"`
SendTime time.Time `gorm:"column:send_time" json:"sendTime"`
SendTime time.Time `gorm:"column:send_time;;index:search" json:"sendTime"`
CreateTime time.Time `gorm:"column:create_time" json:"createTime"`
Ex string `gorm:"column:ex;type:varchar(1024)" json:"ex"`
}
@@ -1,6 +1,7 @@
package im_mysql_model
import (
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/db"
"Open_IM/pkg/common/log"
"Open_IM/pkg/utils"
@@ -15,8 +16,10 @@ func GetChatLog(chatLog db.ChatLog, pageNumber, showNumber int32) ([]db.ChatLog,
if chatLog.SessionType != 0 {
db = db.Where("session_type = ?", chatLog.SessionType)
}
if chatLog.ContentType != 0 {
if chatLog.ContentType == 1 {
db = db.Where("content_type = ?", chatLog.ContentType)
} else if chatLog.ContentType == 2 {
db = db.Where("content_type in (?)", []int{constant.GroupChatType, constant.SuperGroupChatType})
}
if chatLog.SendID != "" {
db = db.Where("send_id = ?", chatLog.SendID)