Merge branch 'errcode' of github.com:OpenIMSDK/Open-IM-Server into errcode

# Conflicts:
#	pkg/common/mw/rpc_server_interceptor.go
This commit is contained in:
wangchuxiao 2023-03-15 15:56:13 +08:00
parent fab8277086
commit 4866e88eab
2 changed files with 1 additions and 21 deletions

View File

@ -41,14 +41,6 @@ func newMysqlGormDB() (*gorm.DB, error) {
}
dsn = fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=true&loc=Local",
config.Config.Mysql.DBUserName, config.Config.Mysql.DBPassword, config.Config.Mysql.DBAddress[0], config.Config.Mysql.DBDatabaseName)
//newLogger := logger.New(
// Writer{},
// logger.Config{
// SlowThreshold: time.Duration(config.Config.Mysql.SlowThreshold) * time.Millisecond, // Slow SQL threshold
// LogLevel: logger.LogLevel(config.Config.Mysql.LogLevel), // Log level
// IgnoreRecordNotFoundError: true, // Ignore ErrRecordNotFound error for logger
// },
//)
sqlLogger := NewSqlLogger(logger.LogLevel(config.Config.Mysql.LogLevel), true, time.Duration(config.Config.Mysql.SlowThreshold)*time.Millisecond)
db, err = gorm.Open(mysql.Open(dsn), &gorm.Config{
Logger: sqlLogger,
@ -149,15 +141,3 @@ func (l SqlLogger) Trace(ctx context.Context, begin time.Time, fc func() (sql st
}
}
}
type Writer struct{}
func (w Writer) Printf(format string, args ...interface{}) {
s := fmt.Sprintf(format, args...)
l := strings.Split(s, "\n")
if len(l) == 2 {
log.ZDebug(context.Background(), "sql exec detail", "gorm", l[0], "sql", l[1])
} else {
log.ZDebug(context.Background(), "sql exec detail", "sql", s)
}
}

View File

@ -34,7 +34,7 @@ func (u *UserGorm) Update(ctx context.Context, users []*relation.UserModel) (err
// 获取指定用户信息 不存在,也不返回错误
func (u *UserGorm) Find(ctx context.Context, userIDs []string) (users []*relation.UserModel, err error) {
log.ZDebug(ctx, "Find args", "userIDs", userIDs)
err = utils.Wrap(u.DB.Where("user_id in ?", userIDs).Find(&users).Error, "")
err = utils.Wrap(u.DB.Where("user_id in (?)", userIDs).Find(&users).Error, "")
return users, err
}