|
|
|
@ -1,17 +1,20 @@
|
|
|
|
|
package ktgen
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/tal-tech/go-zero/tools/goctl/api/util"
|
|
|
|
|
"log"
|
|
|
|
|
"strings"
|
|
|
|
|
"text/template"
|
|
|
|
|
|
|
|
|
|
"github.com/tal-tech/go-zero/tools/goctl/api/util"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var funcsMap = template.FuncMap{
|
|
|
|
|
"lowCamelCase": lowCamelCase,
|
|
|
|
|
"pathToFuncName": pathToFuncName,
|
|
|
|
|
"parseType": parseType,
|
|
|
|
|
"add": add,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func lowCamelCase(s string) string {
|
|
|
|
|
if len(s) < 1 {
|
|
|
|
|
return ""
|
|
|
|
@ -25,12 +28,13 @@ func pathToFuncName(path string) string {
|
|
|
|
|
path = "/" + path
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
path = strings.Replace(path, "/", "_", -1)
|
|
|
|
|
path = strings.Replace(path, "-", "_", -1)
|
|
|
|
|
path = strings.ReplaceAll(path, "/", "_")
|
|
|
|
|
path = strings.ReplaceAll(path, "-", "_")
|
|
|
|
|
|
|
|
|
|
camel := util.ToCamelCase(path)
|
|
|
|
|
return util.ToLower(camel[:1]) + camel[1:]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func parseType(t string) string {
|
|
|
|
|
t = strings.Replace(t, "*", "", -1)
|
|
|
|
|
if strings.HasPrefix(t, "[]") {
|
|
|
|
|