feat: gen model

This commit is contained in:
Rogee
2024-11-29 17:42:59 +08:00
parent 7bc082abea
commit 725a6de5ab
16 changed files with 348 additions and 60 deletions

View File

@@ -17,18 +17,18 @@ func Provide(opts ...opt.Option) error {
return err
}
return container.Container.Provide(func() (*sql.DB, error) {
return container.Container.Provide(func() (*sql.DB, *Config, error) {
log.Debugf("connect postgres with dsn: '%s'", conf.DSN())
db, err := sql.Open("postgres", conf.DSN())
if err != nil {
return nil, errors.Wrap(err, "connect database")
return nil, nil, errors.Wrap(err, "connect database")
}
if err := db.Ping(); err != nil {
db.Close()
return nil, errors.Wrap(err, "ping database")
return nil, nil, errors.Wrap(err, "ping database")
}
return db, err
return db, &conf, err
}, o.DiOptions()...)
}