mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-27 20:38:41 +08:00
35 lines
644 B
Go
35 lines
644 B
Go
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")
|
|
)
|
|
`
|
|
)
|