goctl added

This commit is contained in:
kim
2020-07-29 17:11:41 +08:00
parent b1975d29a7
commit 121323b8c3
142 changed files with 10690 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
package modelgen
const (
utilTemplateText = `package {{.Package}}
import (
"errors"
{{if .WithCache}}"zero/core/stores/redis"
"zero/core/stores/sqlc"
"zero/core/stores/sqlx"{{end}}
)
{{if .WithCache}}
type CachedModel struct {
table string
conn sqlx.SqlConn
rds *redis.Redis
sqlc.CachedConn
}
func NewCachedModel(conn sqlx.SqlConn, table string, rds *redis.Redis) *CachedModel {
return &CachedModel{
table: table,
conn: conn,
rds: rds,
CachedConn: sqlc.NewCachedConn(conn, rds),
}
}
{{end}}
var (
ErrNotFound = errors.New("not found")
)
`
)