diff --git a/pkg/common/db/relation/mysql_init.go b/pkg/common/db/relation/mysql_init.go index 06ebc0983..59d425c06 100644 --- a/pkg/common/db/relation/mysql_init.go +++ b/pkg/common/db/relation/mysql_init.go @@ -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) - } -} diff --git a/pkg/common/db/relation/user_model.go b/pkg/common/db/relation/user_model.go index bff50c96b..825ea6d48 100644 --- a/pkg/common/db/relation/user_model.go +++ b/pkg/common/db/relation/user_model.go @@ -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 }