This commit is contained in:
wangchuxiao
2022-09-02 11:26:25 +08:00
parent 6774a8594f
commit a317ebd8e7
6 changed files with 39 additions and 33 deletions
@@ -77,7 +77,7 @@ func GetFriendByIDCMS(ownerUserID, friendUserID string) (friendUser *FriendUser,
err = db.DB.MysqlDB.DefaultGormDB().Table("friends").
Select("friends.*, users.name").
Where("friends.owner_user_id=? and friends.friend_user_id=?", ownerUserID, friendUserID).
Joins("left join friends on friends.friend_user_id = users.user_id").
Joins("left join users on friends.friend_user_id = users.user_id").
Take(friendUser).Error
return friendUser, err
}
@@ -37,7 +37,6 @@ func GetChatLog(chatLog db.ChatLog, pageNumber, showNumber int32) ([]db.ChatLog,
}
func GetChatLogCount(chatLog db.ChatLog) (int64, error) {
var chatLogs []db.ChatLog
var count int64
db := db.DB.MysqlDB.DefaultGormDB().Table("chat_logs")
if chatLog.Content != "" {
@@ -62,6 +61,6 @@ func GetChatLogCount(chatLog db.ChatLog) (int64, error) {
db = db.Where("send_time > ? and send_time < ?", chatLog.SendTime, chatLog.SendTime.AddDate(0, 0, 1))
}
err := db.Find(&chatLogs).Count(&count).Error
err := db.Count(&count).Error
return count, err
}