support api templates

This commit is contained in:
kevin
2020-10-15 16:36:49 +08:00
parent 8291eabc2c
commit f904710811
32 changed files with 274 additions and 155 deletions

View File

@@ -5,12 +5,12 @@ import (
"strings"
"github.com/tal-tech/go-zero/tools/goctl/model/sql/template"
"github.com/tal-tech/go-zero/tools/goctl/util"
"github.com/tal-tech/go-zero/tools/goctl/templatex"
"github.com/tal-tech/go-zero/tools/goctl/util/stringx"
)
func genFindOneByField(table Table, withCache bool) (string, string, error) {
t := util.With("findOneByField").Parse(template.FindOneByField)
t := templatex.With("findOneByField").Parse(template.FindOneByField)
var list []string
camelTableName := table.Name.ToCamel()
for _, field := range table.Fields {
@@ -36,7 +36,7 @@ func genFindOneByField(table Table, withCache bool) (string, string, error) {
list = append(list, output.String())
}
if withCache {
out, err := util.With("findOneByFieldExtraMethod").Parse(template.FindOneByFieldExtraMethod).Execute(map[string]interface{}{
out, err := templatex.With("findOneByFieldExtraMethod").Parse(template.FindOneByFieldExtraMethod).Execute(map[string]interface{}{
"upperStartCamelObject": camelTableName,
"primaryKeyLeft": table.CacheKey[table.PrimaryKey.Name.Source()].Left,
"lowerStartCamelObject": stringx.From(camelTableName).UnTitle(),