|
|
@ -1,6 +1,8 @@
|
|
|
|
package generator
|
|
|
|
package generator
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
|
|
|
|
conf "github.com/tal-tech/go-zero/tools/goctl/config"
|
|
|
|
|
|
|
|
"github.com/tal-tech/go-zero/tools/goctl/util/format"
|
|
|
|
"path/filepath"
|
|
|
|
"path/filepath"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
|
|
|
@ -50,7 +52,7 @@ type (
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
func mkdir(ctx *ctx.ProjectContext, proto parser.Proto) (DirContext, error) {
|
|
|
|
func mkdir(ctx *ctx.ProjectContext, proto parser.Proto, cfg *conf.Config) (DirContext, error) {
|
|
|
|
inner := make(map[string]Dir)
|
|
|
|
inner := make(map[string]Dir)
|
|
|
|
etcDir := filepath.Join(ctx.WorkDir, "etc")
|
|
|
|
etcDir := filepath.Join(ctx.WorkDir, "etc")
|
|
|
|
internalDir := filepath.Join(ctx.WorkDir, "internal")
|
|
|
|
internalDir := filepath.Join(ctx.WorkDir, "internal")
|
|
|
@ -59,9 +61,19 @@ func mkdir(ctx *ctx.ProjectContext, proto parser.Proto) (DirContext, error) {
|
|
|
|
serverDir := filepath.Join(internalDir, "server")
|
|
|
|
serverDir := filepath.Join(internalDir, "server")
|
|
|
|
svcDir := filepath.Join(internalDir, "svc")
|
|
|
|
svcDir := filepath.Join(internalDir, "svc")
|
|
|
|
pbDir := filepath.Join(ctx.WorkDir, proto.GoPackage)
|
|
|
|
pbDir := filepath.Join(ctx.WorkDir, proto.GoPackage)
|
|
|
|
callDir := filepath.Join(ctx.WorkDir, strings.ToLower(stringx.From(proto.Service.Name).ToCamel()))
|
|
|
|
sName,err:=format.FileNamingFormat(cfg.NamingFormat,proto.Service.Name)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
callDir := filepath.Join(ctx.WorkDir, sName)
|
|
|
|
if strings.EqualFold(proto.Service.Name, proto.GoPackage) {
|
|
|
|
if strings.EqualFold(proto.Service.Name, proto.GoPackage) {
|
|
|
|
callDir = filepath.Join(ctx.WorkDir, strings.ToLower(stringx.From(proto.Service.Name+"_client").ToCamel()))
|
|
|
|
clientDir, err := format.FileNamingFormat(cfg.NamingFormat, proto.Service.Name+"_client")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
callDir = filepath.Join(ctx.WorkDir, clientDir)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inner[wd] = Dir{
|
|
|
|
inner[wd] = Dir{
|
|
|
|