Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ Using `Dictionary` as an example, the configuration file is as follows `dictiona
disable_pagination: true
fill_gorm_commit: true
fill_router_prefix: true
rewrite:
schema: true
dal: true
biz: true
api: true
tpl_type: "tree"
fields:
- name: Code
Expand Down
22 changes: 21 additions & 1 deletion internal/actions/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,27 @@ func (a *GenerateAction) generate(ctx context.Context, dataItem *schema.S) error
return err
}

err = a.write(ctx, dataItem.Module, dataItem.Name, parser.StructPackageTplPaths[pkgName], tplData, !dataItem.ForceWrite)
var rewrite bool
switch pkgName {
case "schema":
if dataItem.Rewrite != nil && dataItem.Rewrite.Schema {
rewrite = true
}
case "dal":
if dataItem.Rewrite != nil && dataItem.Rewrite.Dal {
rewrite = true
}
case "biz":
if dataItem.Rewrite != nil && dataItem.Rewrite.Biz {
rewrite = true
}
case "api":
if dataItem.Rewrite != nil && dataItem.Rewrite.Api {
rewrite = true
}
}

err = a.write(ctx, dataItem.Module, dataItem.Name, parser.StructPackageTplPaths[pkgName], tplData, !rewrite)
if err != nil {
return err
}
Expand Down
9 changes: 8 additions & 1 deletion internal/schema/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type S struct {
TableName string `yaml:"table_name,omitempty" json:"table_name,omitempty"`
Comment string `yaml:"comment,omitempty" json:"comment,omitempty"`
Outputs []string `yaml:"outputs,omitempty" json:"outputs,omitempty"`
ForceWrite bool `yaml:"force_write,omitempty" json:"force_write,omitempty"`
Rewrite *Rewrite `yaml:"rewrite,omitempty" json:"force_write,omitempty"`
TplType string `yaml:"tpl_type,omitempty" json:"tpl_type,omitempty"` // crud/tree
DisablePagination bool `yaml:"disable_pagination,omitempty" json:"disable_pagination,omitempty"`
DisableDefaultFields bool `yaml:"disable_default_fields,omitempty" json:"disable_default_fields,omitempty"`
Expand Down Expand Up @@ -120,6 +120,13 @@ func (a *S) Format() *S {
return a
}

type Rewrite struct {
Schema bool `yaml:"schema,omitempty" json:"schema,omitempty"`
Dal bool `yaml:"dal,omitempty" json:"dal,omitempty"`
Biz bool `yaml:"biz,omitempty" json:"biz,omitempty"`
Api bool `yaml:"api,omitempty" json:"api,omitempty"`
}

type Field struct {
Name string `yaml:"name,omitempty" json:"name,omitempty"`
Type string `yaml:"type,omitempty" json:"type,omitempty"`
Expand Down