Merge remote-tracking branch 'origin/errcode' into errcode

test-errcode
Gordon 2 years ago
commit 7b17ed6303

@ -48,7 +48,6 @@ func (u *userDatabase) InitOnce(ctx context.Context, users []*relation.UserModel
if len(miss) > 0 {
_ = u.userDB.Create(ctx, miss)
}
return nil
}

@ -13,12 +13,11 @@ type UserGorm struct {
}
func NewUserGorm(db *gorm.DB) relation.UserModelInterface {
return &UserGorm{DB: db.Model(&relation.UserModel{})}
return &UserGorm{DB: db}
}
func (u *UserGorm) db() *gorm.DB {
newDB := *u.DB
return &newDB
return u.DB.Model(&relation.UserModel{})
}
// 插入多条
@ -38,7 +37,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)
log.ZDebug(ctx, "Find args", "userIDs", userIDs, "db", u.db())
err = utils.Wrap(u.db().Where("user_id in (?)", userIDs).Find(&users).Error, "")
return users, err
}

Loading…
Cancel
Save