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 {
|
type {{.ClassName}}Search struct {
|
||||||
dto.Pagination `search:"-"`
|
dto.Pagination `search:"-"`
|
||||||
{{ $tablename := .TBName -}}
|
{{- $tablename := .TBName -}}
|
||||||
{{ range .Columns -}}
|
{{- range .Columns -}}
|
||||||
{{$z := .IsQuery}}
|
{{$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}}"`
|
{{.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 }}
|
{{- end }}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,18 +40,18 @@ func (m *{{.ClassName}}Search) Bind(ctx *gin.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type {{.ClassName}}Control struct {
|
type {{.ClassName}}Control struct {
|
||||||
{{ range .Columns -}}
|
{{- range .Columns -}}
|
||||||
{{$x := .Pk}}
|
{{$x := .Pk}}
|
||||||
{{- if ($x) }}
|
{{- 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 "CreatedAt" -}}
|
||||||
{{- else if eq .GoField "UpdatedAt" -}}
|
{{- else if eq .GoField "UpdatedAt" -}}
|
||||||
{{- else if eq .GoField "DeletedAt" -}}
|
{{- else if eq .GoField "DeletedAt" -}}
|
||||||
{{- else if eq .GoField "CreateBy" -}}
|
{{- else if eq .GoField "CreateBy" -}}
|
||||||
{{- else if eq .GoField "UpdateBy" -}}
|
{{- else if eq .GoField "UpdateBy" -}}
|
||||||
{{- else }}
|
{{- else }}
|
||||||
{{.GoField}} {{.GoType}} `json:"{{.JsonField}}" comment:"{{.ColumnComment}}" vd:"?"`
|
{{.GoField}} {{.GoType}} `json:"{{.JsonField}}" comment:"{{.ColumnComment}}"`
|
||||||
{{end -}}
|
{{- end -}}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ func (s *{{.ClassName}}Control) Bind(ctx *gin.Context) error {
|
|||||||
|
|
||||||
func (s *{{.ClassName}}Control) GenerateM() (common.ActiveRecord, error) {
|
func (s *{{.ClassName}}Control) GenerateM() (common.ActiveRecord, error) {
|
||||||
return &models.{{.ClassName}}{
|
return &models.{{.ClassName}}{
|
||||||
{{ range .Columns -}}
|
{{- range .Columns -}}
|
||||||
{{$x := .Pk}}
|
{{$x := .Pk}}
|
||||||
{{- if ($x) }}
|
{{- if ($x) }}
|
||||||
Model: common.Model{ {{.GoField}}: s.{{.GoField}} },
|
Model: common.Model{ {{.GoField}}: s.{{.GoField}} },
|
||||||
@@ -88,7 +88,7 @@ func (s *{{.ClassName}}Control) GenerateM() (common.ActiveRecord, error) {
|
|||||||
{{- else if eq .GoField "UpdateBy" -}}
|
{{- else if eq .GoField "UpdateBy" -}}
|
||||||
{{- else }}
|
{{- else }}
|
||||||
{{.GoField}}: s.{{.GoField}},
|
{{.GoField}}: s.{{.GoField}},
|
||||||
{{- end }}
|
{{- end -}}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user