mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-13 09:50:00 +08:00
feat: Support projectPkg template variables in config, handler, logic, main, and svc template files (#4939)
This commit is contained in:
@@ -14,10 +14,10 @@ import (
|
||||
//go:embed logic_test.tpl
|
||||
var logicTestTemplate string
|
||||
|
||||
func genLogicTest(dir, rootPkg string, cfg *config.Config, api *spec.ApiSpec) error {
|
||||
func genLogicTest(dir, rootPkg, projectPkg string, cfg *config.Config, api *spec.ApiSpec) error {
|
||||
for _, g := range api.Service.Groups {
|
||||
for _, r := range g.Routes {
|
||||
err := genLogicTestByRoute(dir, rootPkg, cfg, g, r)
|
||||
err := genLogicTestByRoute(dir, rootPkg, projectPkg, cfg, g, r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -26,7 +26,7 @@ func genLogicTest(dir, rootPkg string, cfg *config.Config, api *spec.ApiSpec) er
|
||||
return nil
|
||||
}
|
||||
|
||||
func genLogicTestByRoute(dir, rootPkg string, cfg *config.Config, group spec.Group, route spec.Route) error {
|
||||
func genLogicTestByRoute(dir, rootPkg, projectPkg string, cfg *config.Config, group spec.Group, route spec.Route) error {
|
||||
logic := getLogicName(route)
|
||||
goFile, err := format.FileNamingFormat(cfg.NamingFormat, logic)
|
||||
if err != nil {
|
||||
@@ -73,6 +73,7 @@ func genLogicTestByRoute(dir, rootPkg string, cfg *config.Config, group spec.Gro
|
||||
"requestType": requestType,
|
||||
"hasDoc": len(route.JoinedDoc()) > 0,
|
||||
"doc": getDoc(route.JoinedDoc()),
|
||||
"projectPkg": projectPkg,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user