55 lines
1.2 KiB
Smarty
55 lines
1.2 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"
|
|
. "github.com/go-jet/jet/v2/postgres"
|
|
)
|
|
|
|
type Cond func(BoolExpression) BoolExpression
|
|
|
|
func ExprCond(expr BoolExpression) Cond {
|
|
return func(cond BoolExpression) BoolExpression {
|
|
return cond.AND(expr)
|
|
}
|
|
}
|
|
|
|
func CondTrue(conds ...Cond) BoolExpression {
|
|
cond:= BoolExp(Bool(true))
|
|
for _, c := range conds {
|
|
cond = c(cond)
|
|
}
|
|
return cond
|
|
}
|
|
|
|
func CondJoin(cond Cond, conds ...Cond) []Cond {
|
|
return append([]Cond{cond}, conds...)
|
|
}
|
|
|
|
|
|
var db *sql.DB
|
|
{{- range . }}
|
|
func {{.PascalTable}}Model() *{{.PascalTable}} { return &{{.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 {
|
|
if err := container.Container.Provide(func( _db *sql.DB,) (contracts.Initial, error) {
|
|
db = _db
|
|
return nil, nil
|
|
}, atom.GroupInitial); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|