Skip to content

Commit

Permalink
feat: 调整自动化代码在package模式下的生成逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
piexlMax(奇淼 committed Feb 12, 2025
1 parent ab081d1 commit c71c6c4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
8 changes: 4 additions & 4 deletions server/service/system/auto_code_package.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (s *autoCodePackage) Create(ctx context.Context, info *request.SysAutoCodeP
return errors.Wrap(err, "创建失败!")
}
code := info.AutoCode()
_, asts, creates, err := s.templates(ctx, create, code)
_, asts, creates, err := s.templates(ctx, create, code, true)
if err != nil {
return err
}
Expand Down Expand Up @@ -239,7 +239,7 @@ func (s *autoCodePackage) Templates(ctx context.Context) ([]string, error) {
return templates, nil
}

func (s *autoCodePackage) templates(ctx context.Context, entity model.SysAutoCodePackage, info request.AutoCode) (code map[string]string, asts map[string]ast.Ast, creates map[string]string, err error) {
func (s *autoCodePackage) templates(ctx context.Context, entity model.SysAutoCodePackage, info request.AutoCode, isPackage bool) (code map[string]string, asts map[string]ast.Ast, creates map[string]string, err error) {
code = make(map[string]string)
asts = make(map[string]ast.Ast)
creates = make(map[string]string)
Expand All @@ -252,7 +252,7 @@ func (s *autoCodePackage) templates(ctx context.Context, entity model.SysAutoCod
second := filepath.Join(templateDir, templateDirs[i].Name())
switch templateDirs[i].Name() {
case "server":
if !info.GenerateServer {
if !info.GenerateServer && !isPackage {
break
}
var secondDirs []os.DirEntry
Expand Down Expand Up @@ -602,7 +602,7 @@ func (s *autoCodePackage) templates(ctx context.Context, entity model.SysAutoCod
}
}
case "web":
if !info.GenerateWeb {
if !info.GenerateWeb && !isPackage {
break
}
var secondDirs []os.DirEntry
Expand Down
2 changes: 1 addition & 1 deletion server/service/system/auto_code_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func (s *autoCodeTemplate) Preview(ctx context.Context, info request.AutoCode) (
}

func (s *autoCodeTemplate) generate(ctx context.Context, info request.AutoCode, entity model.SysAutoCodePackage) (map[string]strings.Builder, map[string]string, map[string]utilsAst.Ast, error) {
templates, asts, _, err := AutoCodePackage.templates(ctx, entity, info)
templates, asts, _, err := AutoCodePackage.templates(ctx, entity, info, false)
if err != nil {
return nil, nil, nil, err
}
Expand Down
6 changes: 6 additions & 0 deletions web/src/view/systemTools/autoCode/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,10 @@
for (let key in json) {
form.value[key] = json[key]
}
form.value.generateServer = true
form.value.generateWeb = true
}
}
Expand Down Expand Up @@ -1429,6 +1433,8 @@
form.value.abbreviation = toLowerCase(tbHump)
form.value.description = tbHump + ''
form.value.autoCreateApiToSql = true
form.value.generateServer = true
form.value.generateWeb = true
form.value.fields = []
res.data.columns &&
res.data.columns.forEach((item) => {
Expand Down

0 comments on commit c71c6c4

Please sign in to comment.