54 lines
1.0 KiB
Smarty
54 lines
1.0 KiB
Smarty
// Code generated by the atomctl ; DO NOT EDIT.
|
|
// Code generated by the atomctl ; DO NOT EDIT.
|
|
// Code generated by the atomctl ; DO NOT EDIT.
|
|
package model
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
|
|
"go.ipao.vip/atom"
|
|
"go.ipao.vip/atom/container"
|
|
"go.ipao.vip/atom/contracts"
|
|
"go.ipao.vip/atom/opt"
|
|
)
|
|
|
|
var db *sql.DB
|
|
{{- range . }}
|
|
var {{.PascalTable}}Model *{{.PascalTable}}
|
|
{{- end }}
|
|
|
|
func Transaction(ctx context.Context) (*sql.Tx, error) {
|
|
return db.Begin()
|
|
}
|
|
func DB() *sql.DB {
|
|
return db
|
|
}
|
|
|
|
func Provide(opts ...opt.Option) error {
|
|
{{- range . }}
|
|
if err := container.Container.Provide(func() (*{{.PascalTable}}, error) {
|
|
obj := &{{.PascalTable}}{}
|
|
return obj, nil
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
{{ end }}
|
|
|
|
if err := container.Container.Provide(func(
|
|
_db *sql.DB,
|
|
{{- range . }}
|
|
{{.CamelTable}} *{{.PascalTable}},
|
|
{{- end }}
|
|
) (contracts.Initial, error) {
|
|
db = _db
|
|
{{- range . }}
|
|
{{.PascalTable}}Model = {{.CamelTable}}
|
|
{{- end }}
|
|
|
|
return nil, nil
|
|
}, atom.GroupInitial); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|