feat: Add request.ts (#2901)
* Add request.ts * Update comments * Refactor request filename
This commit is contained in:
@@ -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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user