feat: Add request.ts (#2901)

* Add request.ts

* Update comments

* Refactor request filename
This commit is contained in:
anqiansong
2023-02-20 22:54:25 +08:00
committed by GitHub
parent 64ab00e8e3
commit 03d073a884
5 changed files with 159 additions and 2 deletions

View File

@@ -7,6 +7,7 @@ import (
"github.com/logrusorgru/aurora"
"github.com/spf13/cobra"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/tools/goctl/api/parser"
"github.com/zeromicro/go-zero/tools/goctl/util/pathx"
)
@@ -39,6 +40,10 @@ func TsCommand(_ *cobra.Command, _ []string) error {
return errors.New("missing -dir")
}
if len(webAPI) == 0 {
webAPI = "."
}
api, err := parser.Parse(apiFile)
if err != nil {
fmt.Println(aurora.Red("Failed"))
@@ -51,6 +56,7 @@ func TsCommand(_ *cobra.Command, _ []string) error {
api.Service = api.Service.JoinPrefix()
logx.Must(pathx.MkdirIfNotExist(dir))
logx.Must(genRequest(dir))
logx.Must(genHandler(dir, webAPI, caller, api, unwrapAPI))
logx.Must(genComponents(dir, api))