优化模版生成

This commit is contained in:
linwenxiang committed 2020-09-16 22:42:13 +08:00
1 parent 91f2adb340
commit 6bc3e6c00b
12 files changed
+53 -50

No files matched your search

+7 -6
View File
@@ -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 }}
-2
View File
@@ -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 {
+1 -1
View File
@@ -82,7 +82,7 @@
<el-table-column type="selection" width="55" align="center"/>
{{- range .Columns -}}
{{- $x := .IsList -}}
{{- if ($x) }}
{{- if (eq $x "1") }}
{{- if ne .FkTableName "" -}}
<el-table-column label="{{.ColumnComment}}" align="center" prop="{{.JsonField}}" :formatter="{{.JsonField}}Format" width="100">
<template slot-scope="scope">