This commit is contained in:
wangchuxiao
2022-02-12 17:13:31 +08:00
parent 6de61cb214
commit 52579c5fab
23 changed files with 618 additions and 111 deletions
@@ -12,6 +12,18 @@ func GetChatLog(chatLog db.ChatLog, pageNumber, showNumber int32) ([]db.ChatLog,
return chatLogs, err
}
dbConn.LogMode(true)
err = dbConn.Table("chat_logs").Where(fmt.Sprintf(" content like '%%%s%%' ", chatLog.Content)).Limit(showNumber).Offset(showNumber * (pageNumber - 1)).Find(&chatLogs).Error
err = dbConn.Table("chat_logs").Where(fmt.Sprintf(" content like '%%%s%%'", chatLog.Content)).
Limit(showNumber).Offset(showNumber * (pageNumber - 1)).Find(&chatLogs).Error
return chatLogs, err
}
func GetChatLogCount(chatLog db.ChatLog) (int64, error) {
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
var count int64
if err != nil {
return count, err
}
dbConn.LogMode(true)
err = dbConn.Table("chat_logs").Where(fmt.Sprintf(" content like '%%%s%%' and ", chatLog.Content)).Count(&count).Error
return count, err
}
@@ -159,7 +159,7 @@ func UserIsBlock(userId string) (bool, error) {
return false, err
}
var user db.BlackList
rows := dbConn.Table("black_list").Where("uid=?", userId).First(&user).RowsAffected
rows := dbConn.Table("black_lists").Where("uid=?", userId).First(&user).RowsAffected
if rows >= 1 {
return true, nil
}
@@ -183,7 +183,7 @@ func BlockUser(userId, endDisableTime string) error {
return constant.ErrDB
}
var blockUser db.BlackList
dbConn.Table("black_list").Where("uid=?", userId).First(&blockUser)
dbConn.Table("black_lists").Where("uid=?", userId).First(&blockUser)
if blockUser.UserId != "" {
dbConn.Model(&blockUser).Where("uid=?", blockUser.UserId).Update("end_disable_time", end)
return nil
@@ -222,7 +222,7 @@ func GetBlockUserById(userId string) (BlockUserInfo, error) {
if err != nil {
return blockUserInfo, err
}
if err = dbConn.Table("black_list").Where("uid=?", userId).Find(&blockUser).Error; err != nil {
if err = dbConn.Table("black_lists").Where("uid=?", userId).Find(&blockUser).Error; err != nil {
return blockUserInfo, err
}
user := db.Users{