Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Rabbbit committed Jan 6, 2021
1 parent 663ebc9 commit e96df21
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions cli/actions/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,29 @@ func GenRepo(ctx *cli.Context) error {
if _, err = mkdirIfNotExist("./internal/biz/repos"); err != nil {
return err
}
errorsFile, ex, err := createIfNotExist("./internal/biz/repos/errors.go")
if err != nil {
return err
}
if !ex {
r := codegen.NewRepoGener(nil, nil, "repos", moduleName)
if err := r.GenErrorsCode(errorsFile); err != nil {
return err
}
}

for _, table := range strings.Split(pattern, ",") {
m := codegen.NewPoModelStructInfo(table, url, "repos")
path := fmt.Sprintf("./internal/biz/repos/%s_repo.go", table)
file, ex, err := createIfNotExist(path)
if err != nil {
return nil
}
r := codegen.NewRepoGener(file, m, "repos", moduleName)
if ex {
fmt.Println(color.MagentaString("%s repo file exist , will ignore to write ... ", path))
continue
}
errorsFile, ex, err := createIfNotExist("./internal/biz/repos/errors.go")
if err != nil {
return err
}
if !ex {
if err := r.GenErrorsCode(errorsFile); err != nil {
return err
}
}
m := codegen.NewPoModelStructInfo(table, url, "repos")
r := codegen.NewRepoGener(file, m, "repos", moduleName)
if err = r.GenCode(); err != nil {
return err
}
Expand Down

0 comments on commit e96df21

Please sign in to comment.