pull/351/head
wangchuxiao 2 years ago
parent 06e48516bb
commit a372ef3faa

@ -63,7 +63,7 @@ func GetUserFriendsCMS(ownerUserID, friendUserName string, pageNumber, showNumbe
db := db.DB.MysqlDB.DefaultGormDB().Table("friends"). db := db.DB.MysqlDB.DefaultGormDB().Table("friends").
Select("friends.*, users.name"). Select("friends.*, users.name").
Where("friends.owner_user_id=?", ownerUserID).Limit(int(showNumber)). Where("friends.owner_user_id=?", ownerUserID).Limit(int(showNumber)).
Joins("left join friends on friends.friend_user_id = users.user_id"). Joins("left join users on friends.friend_user_id = users.user_id").
Offset(int(showNumber * (pageNumber - 1))) Offset(int(showNumber * (pageNumber - 1)))
if friendUserName != "" { if friendUserName != "" {
db = db.Where("users.name like ?", fmt.Sprintf("%%%s%%", friendUserName)) db = db.Where("users.name like ?", fmt.Sprintf("%%%s%%", friendUserName))

@ -13,7 +13,7 @@ func GetChatLog(chatLog db.ChatLog, pageNumber, showNumber int32) ([]db.ChatLog,
db := db.DB.MysqlDB.DefaultGormDB().Table("chat_logs"). db := db.DB.MysqlDB.DefaultGormDB().Table("chat_logs").
Limit(int(showNumber)).Offset(int(showNumber * (pageNumber - 1))) Limit(int(showNumber)).Offset(int(showNumber * (pageNumber - 1)))
if chatLog.Content != "" { if chatLog.Content != "" {
db = db.Where(" name like ? ", fmt.Sprintf("%%%s%%", chatLog.Content)) db = db.Where(" content like ? ", fmt.Sprintf("%%%s%%", chatLog.Content))
} }
if chatLog.SessionType == 1 { if chatLog.SessionType == 1 {
db = db.Where("session_type = ?", chatLog.SessionType) db = db.Where("session_type = ?", chatLog.SessionType)
@ -40,7 +40,7 @@ func GetChatLogCount(chatLog db.ChatLog) (int64, error) {
var count int64 var count int64
db := db.DB.MysqlDB.DefaultGormDB().Table("chat_logs") db := db.DB.MysqlDB.DefaultGormDB().Table("chat_logs")
if chatLog.Content != "" { if chatLog.Content != "" {
db = db.Where(" name like ? ", fmt.Sprintf("%%%s%%", chatLog.Content)) db = db.Where(" content like ? ", fmt.Sprintf("%%%s%%", chatLog.Content))
} }
if chatLog.SessionType != 0 { if chatLog.SessionType != 0 {
db = db.Where("session_type = ?", chatLog.SessionType) db = db.Where("session_type = ?", chatLog.SessionType)

Loading…
Cancel
Save