Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
oldme-git committed Oct 25, 2023
1 parent 5fa6f90 commit fdd0db8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
14 changes: 11 additions & 3 deletions cmd/gf/internal/cmd/cmd_gen_ctrl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ import (
func Test_Gen_Ctrl_Default(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
var (
path = gfile.Temp(guid.S())
in = genctrl.CGenCtrlInput{
SrcFolder: gtest.DataPath("genctrl", "api"),
path = gfile.Temp(guid.S())
apiFolder = gtest.DataPath("genctrl", "api")
in = genctrl.CGenCtrlInput{
SrcFolder: apiFolder,
DstFolder: path,
WatchFile: "",
SdkPath: "",
Expand All @@ -44,6 +45,13 @@ func Test_Gen_Ctrl_Default(t *testing.T) {
panic(err)
}

// apiInterface files
var (
genApi = apiFolder + filepath.FromSlash("/article/article.go")
genApiExpect = apiFolder + filepath.FromSlash("/article/article_expect.go.txt")
)
t.Assert(gfile.GetContents(genApi), gfile.GetContents(genApiExpect))

// files
files, err := gfile.ScanDir(path, "*.go", true)
t.AssertNil(err)
Expand Down
3 changes: 1 addition & 2 deletions cmd/gf/internal/cmd/genctrl/genctrl_generate_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ func (c *apiInterfaceGenerator) doGenerate(apiModuleFolderPath string, module st
moduleFilePath = filepath.FromSlash(gfile.Join(apiModuleFolderPath, fmt.Sprintf(`%s.if.go`, module)))
}
// all import paths.
importPathMap.Set("\t"+`"context"`, 1)
importPathMap.Set("\t"+``, 1)
importPathMap.Set("\t"+`"context"`+"\n", 1)
for _, item := range items {
importPathMap.Set(fmt.Sprintf("\t"+`"%s"`, item.Import), 1)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ import (
)

type IArticleV1 interface {
Create(ctx context.Context, req *v1.CreateReq) (res *v1.CreateRes, err error)
Update(ctx context.Context, req *v1.UpdateReq) (res *v1.UpdateRes, err error)
GetList(ctx context.Context, req *v1.GetListReq) (res *v1.GetListRes, err error)
GetOne(ctx context.Context, req *v1.GetOneReq) (res *v1.GetOneRes, err error)
}

type IArticleV2 interface {
Create(ctx context.Context, req *v2.CreateReq) (res *v2.CreateRes, err error)
Update(ctx context.Context, req *v2.UpdateReq) (res *v2.UpdateRes, err error)
}
4 changes: 2 additions & 2 deletions cmd/gf/internal/consts/consts_gen_ctrl_template.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fdd0db8

Please sign in to comment.