goctl added
This commit is contained in:
33
tools/goctl/model/mongomodel/gen/genmethod.go
Normal file
33
tools/goctl/model/mongomodel/gen/genmethod.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package gen
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"zero/tools/goctl/model/mongomodel/utils"
|
||||
)
|
||||
|
||||
func genMethodTemplate(funcDesc FunctionDesc, needCache bool) (template string) {
|
||||
var tmp string
|
||||
switch funcDesc.Type {
|
||||
case functionTypeGet:
|
||||
if needCache {
|
||||
tmp = getTemplate
|
||||
} else {
|
||||
tmp = noCacheGetTemplate
|
||||
}
|
||||
case functionTypeFind:
|
||||
tmp = findTemplate
|
||||
case functionTypeSet:
|
||||
if needCache {
|
||||
tmp = ""
|
||||
} else {
|
||||
tmp = noCacheSetFieldtemplate
|
||||
}
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
tmp = strings.ReplaceAll(tmp, "{{.Name}}", funcDesc.FieldName)
|
||||
tmp = strings.ReplaceAll(tmp, "{{.name}}", utils.UpperCamelToLower(funcDesc.FieldName))
|
||||
tmp = strings.ReplaceAll(tmp, "{{.type}}", funcDesc.FieldType)
|
||||
return tmp
|
||||
}
|
||||
Reference in New Issue
Block a user