feat✨ 优化dto模版
This commit is contained in:
1 parent
e219463505
commit
debe808f83
1 file changed
+10
-10
+10
-10
@@ -12,12 +12,12 @@ import (
|
||||
|
||||
type {{.ClassName}}Search struct {
|
||||
dto.Pagination `search:"-"`
|
||||
{{ $tablename := .TBName -}}
|
||||
{{ range .Columns -}}
|
||||
{{- $tablename := .TBName -}}
|
||||
{{- range .Columns -}}
|
||||
{{$z := .IsQuery}}
|
||||
{{- if ($z) -}}
|
||||
{{- if ($z) }}
|
||||
{{.GoField}} {{.GoType}} `form:"{{.JsonField}}" search:"type:{{if eq .QueryType "EQ"}}exact{{ else if eq .QueryType "NE"}}iexact{{ else if eq .QueryType "LIKE"}}contains{{ else if eq .QueryType "GT"}}gt{{ else if eq .QueryType "GTE"}}gte{{ else if eq .QueryType "LT"}}lt{{ else if eq .QueryType "LTE"}}lte{{- end }};column:{{.ColumnName}};table:{{$tablename}}" comment:"{{.ColumnComment}}"`
|
||||
{{ end -}}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
}
|
||||
|
||||
@@ -40,18 +40,18 @@ func (m *{{.ClassName}}Search) Bind(ctx *gin.Context) error {
|
||||
}
|
||||
|
||||
type {{.ClassName}}Control struct {
|
||||
{{ range .Columns -}}
|
||||
{{- range .Columns -}}
|
||||
{{$x := .Pk}}
|
||||
{{- if ($x) }}
|
||||
{{.GoField}} {{.GoType}} `uri:"{{.JsonField}}" comment:"{{.ColumnComment}}" vd:"?"` // {{.ColumnComment}}
|
||||
{{.GoField}} {{.GoType}} `uri:"{{.JsonField}}" comment:"{{.ColumnComment}}"` // {{.ColumnComment}}
|
||||
{{- else if eq .GoField "CreatedAt" -}}
|
||||
{{- else if eq .GoField "UpdatedAt" -}}
|
||||
{{- else if eq .GoField "DeletedAt" -}}
|
||||
{{- else if eq .GoField "CreateBy" -}}
|
||||
{{- else if eq .GoField "UpdateBy" -}}
|
||||
{{- else }}
|
||||
{{.GoField}} {{.GoType}} `json:"{{.JsonField}}" comment:"{{.ColumnComment}}" vd:"?"`
|
||||
{{end -}}
|
||||
{{.GoField}} {{.GoType}} `json:"{{.JsonField}}" comment:"{{.ColumnComment}}"`
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ func (s *{{.ClassName}}Control) Bind(ctx *gin.Context) error {
|
||||
|
||||
func (s *{{.ClassName}}Control) GenerateM() (common.ActiveRecord, error) {
|
||||
return &models.{{.ClassName}}{
|
||||
{{ range .Columns -}}
|
||||
{{- range .Columns -}}
|
||||
{{$x := .Pk}}
|
||||
{{- if ($x) }}
|
||||
Model: common.Model{ {{.GoField}}: s.{{.GoField}} },
|
||||
@@ -88,7 +88,7 @@ func (s *{{.ClassName}}Control) GenerateM() (common.ActiveRecord, error) {
|
||||
{{- else if eq .GoField "UpdateBy" -}}
|
||||
{{- else }}
|
||||
{{.GoField}}: s.{{.GoField}},
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user