diff --git a/pkg/common/db/mysql_model/im_mysql_model/demo_model.go b/pkg/common/db/mysql_model/im_mysql_model/demo_model.go index 897e5e212..eff3050be 100644 --- a/pkg/common/db/mysql_model/im_mysql_model/demo_model.go +++ b/pkg/common/db/mysql_model/im_mysql_model/demo_model.go @@ -33,7 +33,7 @@ func ResetPassword(account, password string) error { Password: password, } dbConn, err := db.DB.MysqlDB.DefaultGormDB() - dbConn.LogMode(true) + dbConn.LogMode(false) if err != nil { return err } diff --git a/pkg/common/db/mysql_model/im_mysql_model/group_member_model.go b/pkg/common/db/mysql_model/im_mysql_model/group_member_model.go index b0ffbd4ee..289a157fc 100644 --- a/pkg/common/db/mysql_model/im_mysql_model/group_member_model.go +++ b/pkg/common/db/mysql_model/im_mysql_model/group_member_model.go @@ -71,7 +71,7 @@ func GetGroupMemberIDListByGroupID(groupID string) ([]string, error) { if err != nil { return nil, err } - dbConn.LogMode(true) + dbConn.LogMode(false) var groupMembers []db.GroupMember err = dbConn.Table("group_members").Select("user_id").Where("group_id=?", groupID).Find(&groupMembers).Error if err != nil { @@ -279,7 +279,7 @@ func GetGroupMembersCount(groupId, userName string) (int32, error) { if err != nil { return count, err } - dbConn.LogMode(true) + dbConn.LogMode(false) if err := dbConn.Table("group_members").Where("group_id=?", groupId).Where(fmt.Sprintf(" nickname like '%%%s%%' ", userName)).Count(&count).Error; err != nil { return count, err } diff --git a/pkg/common/db/mysql_model/im_mysql_model/group_request_model.go b/pkg/common/db/mysql_model/im_mysql_model/group_request_model.go index 836f3f0bf..5e27cc3d2 100644 --- a/pkg/common/db/mysql_model/im_mysql_model/group_request_model.go +++ b/pkg/common/db/mysql_model/im_mysql_model/group_request_model.go @@ -123,7 +123,7 @@ func GetUserReqGroupByUserID(userID string) ([]db.GroupRequest, error) { if err != nil { return nil, err } - dbConn.LogMode(true) + dbConn.LogMode(false) err = dbConn.Table("group_requests").Where("user_id=?", userID).Find(&groupRequestList).Error return groupRequestList, err } diff --git a/pkg/common/db/mysql_model/im_mysql_model/message_cms.go b/pkg/common/db/mysql_model/im_mysql_model/message_cms.go index eb4b0cc52..29fb650cf 100644 --- a/pkg/common/db/mysql_model/im_mysql_model/message_cms.go +++ b/pkg/common/db/mysql_model/im_mysql_model/message_cms.go @@ -13,7 +13,7 @@ func GetChatLog(chatLog db.ChatLog, pageNumber, showNumber int32) ([]db.ChatLog, if err != nil { return chatLogs, err } - dbConn.LogMode(true) + dbConn.LogMode(false) db := dbConn.Table("chat_logs"). Where(fmt.Sprintf(" content like '%%%s%%'", chatLog.Content)). Limit(showNumber).Offset(showNumber * (pageNumber - 1)) @@ -43,7 +43,7 @@ func GetChatLogCount(chatLog db.ChatLog) (int64, error) { if err != nil { return count, err } - dbConn.LogMode(true) + dbConn.LogMode(false) db := dbConn.Table("chat_logs"). Where(fmt.Sprintf(" content like '%%%s%%'", chatLog.Content)) if chatLog.SessionType != 0 { @@ -65,4 +65,4 @@ func GetChatLogCount(chatLog db.ChatLog) (int64, error) { err = db.Find(&chatLogs).Count(&count).Error return count, err -} \ No newline at end of file +} diff --git a/pkg/common/db/mysql_model/im_mysql_model/statistics_model.go b/pkg/common/db/mysql_model/im_mysql_model/statistics_model.go index 097c83185..aa07c1688 100644 --- a/pkg/common/db/mysql_model/im_mysql_model/statistics_model.go +++ b/pkg/common/db/mysql_model/im_mysql_model/statistics_model.go @@ -10,7 +10,7 @@ func GetActiveUserNum(from, to time.Time) (int32, error) { if err != nil { return 0, err } - dbConn.LogMode(true) + dbConn.LogMode(false) var num int32 err = dbConn.Table("chat_logs").Select("count(distinct(send_id))").Where("create_time >= ? and create_time <= ?", from, to).Count(&num).Error return num, err @@ -21,7 +21,7 @@ func GetIncreaseUserNum(from, to time.Time) (int32, error) { if err != nil { return 0, err } - dbConn.LogMode(true) + dbConn.LogMode(false) var num int32 err = dbConn.Table("users").Where("create_time >= ? and create_time <= ?", from, to).Count(&num).Error return num, err @@ -32,7 +32,7 @@ func GetTotalUserNum() (int32, error) { if err != nil { return 0, err } - dbConn.LogMode(true) + dbConn.LogMode(false) var num int32 err = dbConn.Table("users").Count(&num).Error return num, err @@ -43,7 +43,7 @@ func GetTotalUserNumByDate(to time.Time) (int32, error) { if err != nil { return 0, err } - dbConn.LogMode(true) + dbConn.LogMode(false) var num int32 err = dbConn.Table("users").Where("create_time <= ?", to).Count(&num).Error return num, err @@ -54,7 +54,7 @@ func GetPrivateMessageNum(from, to time.Time) (int32, error) { if err != nil { return 0, err } - dbConn.LogMode(true) + dbConn.LogMode(false) var num int32 err = dbConn.Table("chat_logs").Where("create_time >= ? and create_time <= ? and session_type = ?", from, to, 1).Count(&num).Error return num, err @@ -65,7 +65,7 @@ func GetGroupMessageNum(from, to time.Time) (int32, error) { if err != nil { return 0, err } - dbConn.LogMode(true) + dbConn.LogMode(false) var num int32 err = dbConn.Table("chat_logs").Where("create_time >= ? and create_time <= ? and session_type = ?", from, to, 2).Count(&num).Error return num, err @@ -76,7 +76,7 @@ func GetIncreaseGroupNum(from, to time.Time) (int32, error) { if err != nil { return 0, err } - dbConn.LogMode(true) + dbConn.LogMode(false) var num int32 err = dbConn.Table("groups").Where("create_time >= ? and create_time <= ?", from, to).Count(&num).Error return num, err @@ -87,7 +87,7 @@ func GetTotalGroupNum() (int32, error) { if err != nil { return 0, err } - dbConn.LogMode(true) + dbConn.LogMode(false) var num int32 err = dbConn.Table("groups").Count(&num).Error return num, err @@ -98,7 +98,7 @@ func GetGroupNum(to time.Time) (int32, error) { if err != nil { return 0, err } - dbConn.LogMode(true) + dbConn.LogMode(false) var num int32 err = dbConn.Table("groups").Where("create_time <= ?", to).Count(&num).Error return num, err @@ -116,7 +116,7 @@ func GetActiveGroups(from, to time.Time, limit int) ([]*activeGroup, error) { if err != nil { return activeGroups, err } - dbConn.LogMode(true) + dbConn.LogMode(false) err = dbConn.Table("chat_logs").Select("recv_id, count(*) as message_num").Where("create_time >= ? and create_time <= ? and session_type = ?", from, to, 2).Group("recv_id").Limit(limit).Order("message_num DESC").Find(&activeGroups).Error for _, activeGroup := range activeGroups { group := db.Group{ @@ -140,7 +140,7 @@ func GetActiveUsers(from, to time.Time, limit int) ([]*activeUser, error) { if err != nil { return activeUsers, err } - dbConn.LogMode(true) + dbConn.LogMode(false) err = dbConn.Table("chat_logs").Select("send_id, count(*) as message_num").Where("create_time >= ? and create_time <= ? and session_type = ?", from, to, 1).Group("send_id").Limit(limit).Order("message_num DESC").Find(&activeUsers).Error for _, activeUser := range activeUsers { user := db.User{ diff --git a/pkg/common/db/mysql_model/im_mysql_model/user_model.go b/pkg/common/db/mysql_model/im_mysql_model/user_model.go index 5719371c5..003b7afa7 100644 --- a/pkg/common/db/mysql_model/im_mysql_model/user_model.go +++ b/pkg/common/db/mysql_model/im_mysql_model/user_model.go @@ -92,7 +92,7 @@ func UpdateUserInfo(user db.User) error { if err != nil { return err } - dbConn.LogMode(true) + dbConn.LogMode(false) err = dbConn.Table("users").Where("user_id=?", user.UserID).Update(&user).Error return err } @@ -112,7 +112,7 @@ func SelectAllUserID() ([]string, error) { func SelectSomeUserID(userIDList []string) ([]string, error) { dbConn, err := db.DB.MysqlDB.DefaultGormDB() - dbConn.LogMode(true) + dbConn.LogMode(false) if err != nil { return nil, err } @@ -131,7 +131,7 @@ func GetUsers(showNumber, pageNumber int32) ([]db.User, error) { if err != nil { return users, err } - dbConn.LogMode(true) + dbConn.LogMode(false) err = dbConn.Table("users").Limit(showNumber).Offset(showNumber * (pageNumber - 1)).Find(&users).Error if err != nil { return users, err @@ -204,7 +204,7 @@ func UnBlockUser(userId string) error { if err != nil { return err } - dbConn.LogMode(true) + dbConn.LogMode(false) result := dbConn.Where("uid=?", userId).Delete(&db.BlackList{}) return result.Error } @@ -248,7 +248,7 @@ func GetBlockUsers(showNumber, pageNumber int32) ([]BlockUserInfo, error) { if err != nil { return blockUserInfos, err } - dbConn.LogMode(true) + dbConn.LogMode(false) if err = dbConn.Limit(showNumber).Offset(showNumber * (pageNumber - 1)).Find(&blockUsers).Error; err != nil { return blockUserInfos, err } @@ -275,7 +275,7 @@ func GetUserByName(userName string, showNumber, pageNumber int32) ([]db.User, er if err != nil { return users, err } - dbConn.LogMode(true) + dbConn.LogMode(false) err = dbConn.Table("users").Where(fmt.Sprintf(" name like '%%%s%%' ", userName)).Limit(showNumber).Offset(showNumber * (pageNumber - 1)).Find(&users).Error return users, err } @@ -285,7 +285,7 @@ func GetUsersCount(user db.User) (int32, error) { if err != nil { return 0, err } - dbConn.LogMode(true) + dbConn.LogMode(false) var count int32 if err := dbConn.Table("users").Where(fmt.Sprintf(" name like '%%%s%%' ", user.Nickname)).Count(&count).Error; err != nil { return 0, err @@ -298,7 +298,7 @@ func GetBlockUsersNumCount() (int32, error) { if err != nil { return 0, err } - dbConn.LogMode(true) + dbConn.LogMode(false) var count int32 if err := dbConn.Model(&db.BlackList{}).Count(&count).Error; err != nil { return 0, err @@ -311,7 +311,7 @@ func SetConversation(conversation db.Conversation) error { if err != nil { return err } - dbConn.LogMode(true) + dbConn.LogMode(false) newConversation := conversation if dbConn.Model(&db.Conversation{}).Find(&newConversation).RowsAffected == 0 { log.NewDebug("", utils.GetSelfFuncName(), "conversation", conversation, "not exist in db, create") @@ -330,7 +330,7 @@ func PeerUserSetConversation(conversation db.Conversation) error { if err != nil { return err } - dbConn.LogMode(true) + dbConn.LogMode(false) newConversation := conversation if dbConn.Model(&db.Conversation{}).Find(&newConversation).RowsAffected == 0 { log.NewDebug("", utils.GetSelfFuncName(), "conversation", conversation, "not exist in db, create") @@ -349,7 +349,7 @@ func SetRecvMsgOpt(conversation db.Conversation) error { if err != nil { return err } - dbConn.LogMode(true) + dbConn.LogMode(false) newConversation := conversation if dbConn.Model(&db.Conversation{}).Find(&newConversation).RowsAffected == 0 { log.NewDebug("", utils.GetSelfFuncName(), "conversation", conversation, "not exist in db, create") @@ -369,7 +369,7 @@ func GetUserAllConversations(ownerUserID string) ([]db.Conversation, error) { if err != nil { return conversations, err } - dbConn.LogMode(true) + dbConn.LogMode(false) err = dbConn.Model(&db.Conversation{}).Where("owner_user_id=?", ownerUserID).Find(&conversations).Error return conversations, err }