From 302c3d002ed7190e5ff873a0a28d9276c60727fd Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Wed, 7 Aug 2024 20:25:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=8E=B7=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dao/im.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dao/im.go b/dao/im.go index 27dc50b..0530e7d 100644 --- a/dao/im.go +++ b/dao/im.go @@ -57,7 +57,8 @@ func GetMsgUserByIndex(from_user_id, to_user_id, msg_type, index, status int) ([ res = DB.Debug().Where("from_user_id = ? and to_user_id = ? and type = ? and status = ? ", from_user_id, to_user_id, msg_type, status).Order("created_at DESC").Limit(20 * index).Find(&msgs) } else if msg_type == 1 { //单聊,只有两个人的消息 - res = DB.Debug().Where("(from_user_id = ? AND to_user_id = ?) or (from_user_id = ? AND to_user_id = ?) and type = ? ", from_user_id, to_user_id, to_user_id, from_user_id, msg_type).Order("created_at DESC").Limit(20 * index).Find(&msgs) + res = DB.Debug().Raw("select * from messages where (from_user_id = ? AND to_user_id = ?) or (from_user_id = ? AND to_user_id = ?) and type = ? order by created_at desc limit ?", from_user_id, to_user_id, to_user_id, from_user_id, msg_type, 20*index).Scan(&msgs) + //res = DB.Debug().Where("(from_user_id = ? AND to_user_id = ?) or (from_user_id = ? AND to_user_id = ?) and type = ? ", from_user_id, to_user_id, to_user_id, from_user_id, msg_type).Order("created_at DESC").Limit(20 * index).Find(&msgs) } else { res = DB.Debug().Where("from_user_id = ? and to_user_id = ? and type = ? ", from_user_id, to_user_id, msg_type).Order("created_at DESC").Limit(20 * index).Find(&msgs) }