mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-07 15:10:01 +08:00
feat: Support projectPkg template variables in config, handler, logic, main, and svc template files (#4939)
This commit is contained in:
@@ -15,7 +15,7 @@ import (
|
||||
//go:embed handler_test.tpl
|
||||
var handlerTestTemplate string
|
||||
|
||||
func genHandlerTest(dir, rootPkg string, cfg *config.Config, group spec.Group, route spec.Route) error {
|
||||
func genHandlerTest(dir, rootPkg, projectPkg string, cfg *config.Config, group spec.Group, route spec.Route) error {
|
||||
handler := getHandlerName(route)
|
||||
handlerPath := getHandlerFolderPath(group, route)
|
||||
pkgName := handlerPath[strings.LastIndex(handlerPath, "/")+1:]
|
||||
@@ -50,14 +50,15 @@ func genHandlerTest(dir, rootPkg string, cfg *config.Config, group spec.Group, r
|
||||
"HasRequest": len(route.RequestTypeName()) > 0,
|
||||
"HasDoc": len(route.JoinedDoc()) > 0,
|
||||
"Doc": getDoc(route.JoinedDoc()),
|
||||
"projectPkg": projectPkg,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func genHandlersTest(dir, rootPkg string, cfg *config.Config, api *spec.ApiSpec) error {
|
||||
func genHandlersTest(dir, rootPkg, projectPkg string, cfg *config.Config, api *spec.ApiSpec) error {
|
||||
for _, group := range api.Service.Groups {
|
||||
for _, route := range group.Routes {
|
||||
if err := genHandlerTest(dir, rootPkg, cfg, group, route); err != nil {
|
||||
if err := genHandlerTest(dir, rootPkg, projectPkg, cfg, group, route); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user