forked from zeromicro/go-zero
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
33 lines (28 loc) · 756 Bytes
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package gen
import (
"github.com/tal-tech/go-zero/tools/goctl/model/sql/template"
"github.com/tal-tech/go-zero/tools/goctl/util"
)
func genTypes(table Table, methods string, withCache bool) (string, error) {
fields := table.Fields
fieldsString, err := genFields(fields)
if err != nil {
return "", err
}
text, err := util.LoadTemplate(category, typesTemplateFile, template.Types)
if err != nil {
return "", err
}
output, err := util.With("types").
Parse(text).
Execute(map[string]interface{}{
"withCache": withCache,
"method": methods,
"upperStartCamelObject": table.Name.ToCamel(),
"fields": fieldsString,
})
if err != nil {
return "", err
}
return output.String(), nil
}