Skip to content

Commit

Permalink
fix(jzero): fix gen model by sql
Browse files Browse the repository at this point in the history
  • Loading branch information
jaronnie committed Jun 4, 2024
1 parent d0c672a commit 5f817fa
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions internal/gen/gensql.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type JzeroSql struct {
}

func (js *JzeroSql) Gen() error {
sqlDir := filepath.Join(js.Wd, "app", "desc", "sql")
sqlDir := filepath.Join(js.Wd, js.AppDir, "desc", "sql")
if f, err := os.Stat(sqlDir); err == nil && f.IsDir() {
fs, err := os.ReadDir(sqlDir)
if err != nil {
Expand All @@ -29,7 +29,11 @@ func (js *JzeroSql) Gen() error {
if !f.IsDir() && strings.HasSuffix(f.Name(), ".sql") {
sqlFilePath := filepath.Join(sqlDir, f.Name())
fmt.Printf("%s sql file %s\n", color.WithColor("Using", color.FgGreen), sqlFilePath)
command := fmt.Sprintf("goctl model mysql ddl --src app/desc/sql/%s --dir ./app/internal/model/%s --home %s --style %s", f.Name(), f.Name()[0:len(f.Name())-len(path.Ext(f.Name()))], filepath.Join(js.Wd, ".template", "go-zero"), js.Style)
dir := js.AppDir
if dir == "" {
dir = "."
}
command := fmt.Sprintf("goctl model mysql ddl --src %s/desc/sql/%s --dir %s/internal/model/%s --home %s --style %s", dir, f.Name(), dir, f.Name()[0:len(f.Name())-len(path.Ext(f.Name()))], filepath.Join(js.Wd, ".template", "go-zero"), js.Style)
_, err = execx.Run(command, js.Wd)
if err != nil {
return err
Expand Down

0 comments on commit 5f817fa

Please sign in to comment.