|
|
@ -7,7 +7,6 @@ import (
|
|
|
|
"text/template"
|
|
|
|
"text/template"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/iancoleman/strcase"
|
|
|
|
"github.com/iancoleman/strcase"
|
|
|
|
"github.com/tal-tech/go-zero/core/logx"
|
|
|
|
|
|
|
|
"github.com/tal-tech/go-zero/tools/goctl/api/spec"
|
|
|
|
"github.com/tal-tech/go-zero/tools/goctl/api/spec"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -116,7 +115,6 @@ object Api{
|
|
|
|
func genBase(dir, pkg string, api *spec.ApiSpec) error {
|
|
|
|
func genBase(dir, pkg string, api *spec.ApiSpec) error {
|
|
|
|
e := os.MkdirAll(dir, 0755)
|
|
|
|
e := os.MkdirAll(dir, 0755)
|
|
|
|
if e != nil {
|
|
|
|
if e != nil {
|
|
|
|
logx.Error(e)
|
|
|
|
|
|
|
|
return e
|
|
|
|
return e
|
|
|
|
}
|
|
|
|
}
|
|
|
|
path := filepath.Join(dir, "BaseApi.kt")
|
|
|
|
path := filepath.Join(dir, "BaseApi.kt")
|
|
|
@ -126,19 +124,16 @@ func genBase(dir, pkg string, api *spec.ApiSpec) error {
|
|
|
|
|
|
|
|
|
|
|
|
file, e := os.OpenFile(path, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644)
|
|
|
|
file, e := os.OpenFile(path, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644)
|
|
|
|
if e != nil {
|
|
|
|
if e != nil {
|
|
|
|
logx.Error(e)
|
|
|
|
|
|
|
|
return e
|
|
|
|
return e
|
|
|
|
}
|
|
|
|
}
|
|
|
|
defer file.Close()
|
|
|
|
defer file.Close()
|
|
|
|
|
|
|
|
|
|
|
|
t, e := template.New("n").Parse(apiBaseTemplate)
|
|
|
|
t, e := template.New("n").Parse(apiBaseTemplate)
|
|
|
|
if e != nil {
|
|
|
|
if e != nil {
|
|
|
|
logx.Error(e)
|
|
|
|
|
|
|
|
return e
|
|
|
|
return e
|
|
|
|
}
|
|
|
|
}
|
|
|
|
e = t.Execute(file, pkg)
|
|
|
|
e = t.Execute(file, pkg)
|
|
|
|
if e != nil {
|
|
|
|
if e != nil {
|
|
|
|
logx.Error(e)
|
|
|
|
|
|
|
|
return e
|
|
|
|
return e
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
@ -150,13 +145,11 @@ func genApi(dir, pkg string, api *spec.ApiSpec) error {
|
|
|
|
|
|
|
|
|
|
|
|
e := os.MkdirAll(dir, 0755)
|
|
|
|
e := os.MkdirAll(dir, 0755)
|
|
|
|
if e != nil {
|
|
|
|
if e != nil {
|
|
|
|
logx.Error(e)
|
|
|
|
|
|
|
|
return e
|
|
|
|
return e
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
file, e := os.OpenFile(path, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644)
|
|
|
|
file, e := os.OpenFile(path, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644)
|
|
|
|
if e != nil {
|
|
|
|
if e != nil {
|
|
|
|
logx.Error(e)
|
|
|
|
|
|
|
|
return e
|
|
|
|
return e
|
|
|
|
}
|
|
|
|
}
|
|
|
|
defer file.Close()
|
|
|
|
defer file.Close()
|
|
|
|