优化模版生成
This commit is contained in:
1 parent
91f2adb340
commit
6bc3e6c00b
12 files changed
+53
-50
No files matched your search
@@ -46,12 +46,13 @@ type {{.ClassName}}Control struct {
|
||||
{{ range .Columns -}}
|
||||
{{$x := .Pk}}
|
||||
{{- if ($x) }}
|
||||
{{.GoField}} uint `json:"{{.JsonField}}" comment:"{{.ColumnComment}}"` // {{.ColumnComment}}
|
||||
{{.GoField}} uint `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" -}}
|
||||
|
||||
{{.GoField}} uint `json:"{{.JsonField}}" comment:"{{.ColumnComment}}"`
|
||||
{{- else }}
|
||||
|
||||
{{.GoField}} {{.GoType}} `json:"{{.JsonField}}" comment:"{{.ColumnComment}}"`
|
||||
@@ -60,6 +61,9 @@ type {{.ClassName}}Control struct {
|
||||
}
|
||||
|
||||
func (s *{{.ClassName}}Control) Bind(ctx *gin.Context) error {
|
||||
if err := ctx.BindUri(s); err != nil {
|
||||
return err
|
||||
}
|
||||
return ctx.Bind(s)
|
||||
}
|
||||
|
||||
@@ -78,10 +82,7 @@ func (s *{{.ClassName}}Control) GenerateM() (common.ActiveRecord, error) {
|
||||
{{- else if eq .GoField "UpdatedAt" -}}
|
||||
{{- else if eq .GoField "DeletedAt" -}}
|
||||
{{- else if eq .GoField "CreateBy" -}}
|
||||
ControlBy: common.ControlBy{
|
||||
CreateBy: s.CreateBy,
|
||||
UpdateBy: s.UpdateBy,
|
||||
},
|
||||
|
||||
|
||||
{{- else if eq .GoField "UpdateBy" -}}
|
||||
{{- else }}
|
||||
|
||||
@@ -27,8 +27,6 @@ type {{.ClassName}} struct {
|
||||
{{- else }}
|
||||
{{.GoField}} {{.GoType}} `json:"{{.JsonField}}" gorm:"type:{{.ColumnType}};comment:{{- if eq .ColumnComment "" -}}{{.GoField}}{{- else -}}{{.ColumnComment}}{{end -}}"` // {{end -}}
|
||||
{{- end }}
|
||||
DataScope string `json:"dataScope" gorm:"-"`
|
||||
Params string `json:"params" gorm:"-"`
|
||||
}
|
||||
|
||||
func ({{.ClassName}}) TableName() string {
|
||||
|
||||
Reference in new issue
Block a user