feature model interface (#222)

* make variable declaration more concise

* add model interface

* optimize interface methods

* fix: go test failed

* warp returns

* optimize
This commit is contained in:
Keson
2020-11-24 22:36:23 +08:00
committed by GitHub
parent b9ac51b6c3
commit 6e57f6c527
21 changed files with 414 additions and 232 deletions

View File

@@ -8,7 +8,7 @@ import (
"github.com/tal-tech/go-zero/tools/goctl/util/stringx"
)
func genUpdate(table Table, withCache bool) (string, error) {
func genUpdate(table Table, withCache bool) (string, string, error) {
expressionValues := make([]string, 0)
for _, filed := range table.Fields {
camel := filed.Name.ToCamel()
@@ -24,7 +24,7 @@ func genUpdate(table Table, withCache bool) (string, error) {
camelTableName := table.Name.ToCamel()
text, err := util.LoadTemplate(category, updateTemplateFile, template.Update)
if err != nil {
return "", err
return "", "", err
}
output, err := util.With("update").
@@ -39,8 +39,23 @@ func genUpdate(table Table, withCache bool) (string, error) {
"expressionValues": strings.Join(expressionValues, ", "),
})
if err != nil {
return "", nil
return "", "", nil
}
return output.String(), nil
// update interface method
text, err = util.LoadTemplate(category, updateMethodTemplateFile, template.UpdateMethod)
if err != nil {
return "", "", err
}
updateMethodOutput, err := util.With("updateMethod").
Parse(text).
Execute(map[string]interface{}{
"upperStartCamelObject": camelTableName,
})
if err != nil {
return "", "", nil
}
return output.String(), updateMethodOutput.String(), nil
}