go-zero/tools/goctl/model/sql/gen/imports.go
Kevin Wan eab904af64
chore: update goctl interface{} to any (#2819)
* chore: update goctl interface{} to any

* chore: update goctl interface{} to any
2023-01-24 17:51:03 +08:00

44 lines
1016 B
Go

package gen
import (
"github.com/zeromicro/go-zero/tools/goctl/model/sql/template"
"github.com/zeromicro/go-zero/tools/goctl/util"
"github.com/zeromicro/go-zero/tools/goctl/util/pathx"
)
func genImports(table Table, withCache, timeImport bool) (string, error) {
if withCache {
text, err := pathx.LoadTemplate(category, importsTemplateFile, template.Imports)
if err != nil {
return "", err
}
buffer, err := util.With("import").Parse(text).Execute(map[string]any{
"time": timeImport,
"containsPQ": table.ContainsPQ,
"data": table,
})
if err != nil {
return "", err
}
return buffer.String(), nil
}
text, err := pathx.LoadTemplate(category, importsWithNoCacheTemplateFile, template.ImportsNoCache)
if err != nil {
return "", err
}
buffer, err := util.With("import").Parse(text).Execute(map[string]any{
"time": timeImport,
"containsPQ": table.ContainsPQ,
"data": table,
})
if err != nil {
return "", err
}
return buffer.String(), nil
}