mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-09-03 05:39:58 +08:00
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:
parent
fab8277086
commit
4866e88eab
@ -41,14 +41,6 @@ func newMysqlGormDB() (*gorm.DB, error) {
|
|||||||
}
|
}
|
||||||
dsn = fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=true&loc=Local",
|
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)
|
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)
|
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{
|
db, err = gorm.Open(mysql.Open(dsn), &gorm.Config{
|
||||||
Logger: sqlLogger,
|
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -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) {
|
func (u *UserGorm) Find(ctx context.Context, userIDs []string) (users []*relation.UserModel, err error) {
|
||||||
log.ZDebug(ctx, "Find args", "userIDs", userIDs)
|
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
|
return users, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user