mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-22 02:27:57 +00:00
模版修改
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
"go-admin/app/admin/models"
|
"go-admin/app/admin/models"
|
||||||
"go-admin/common/dto"
|
"go-admin/common/dto"
|
||||||
common "go-admin/common/models"
|
common "go-admin/common/models"
|
||||||
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type {{.ClassName}}Search struct {
|
type {{.ClassName}}Search struct {
|
||||||
@@ -13,7 +14,7 @@ type {{.ClassName}}Search struct {
|
|||||||
{{ 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}}"` // {{.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 }}
|
||||||
@@ -44,18 +45,18 @@ type {{.ClassName}}Control struct {
|
|||||||
{{ range .Columns -}}
|
{{ range .Columns -}}
|
||||||
{{$x := .Pk}}
|
{{$x := .Pk}}
|
||||||
{{- if ($x) }}
|
{{- if ($x) }}
|
||||||
{{.GoField}} uint `json:"{{.JsonField}}"` // {{.ColumnComment}}
|
{{.GoField}} uint `json:"{{.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" -}}
|
||||||
|
|
||||||
{{.GoField}} uint `json:"{{.JsonField}}"` // {{.ColumnComment}}
|
{{.GoField}} uint `json:"{{.JsonField}}" comment:"{{.ColumnComment}}"`
|
||||||
{{- else if eq .GoField "UpdateBy" -}}
|
{{- else if eq .GoField "UpdateBy" -}}
|
||||||
|
|
||||||
{{.GoField}} uint `json:"{{.JsonField}}"` // {{.ColumnComment}}
|
{{.GoField}} uint `json:"{{.JsonField}}" comment:"{{.ColumnComment}}"`
|
||||||
{{- else }}
|
{{- else }}
|
||||||
{{.GoField}} {{.GoType}} `json:"{{.JsonField}}"` // {{.ColumnComment}}{{end -}}
|
{{.GoField}} {{.GoType}} `json:"{{.JsonField}}" comment:"{{.ColumnComment}}"` {{end -}}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strconv"
|
|
||||||
{{- if eq .IsActions 2 -}}
|
{{- if eq .IsActions 2 -}}
|
||||||
|
|
||||||
"go-admin/common/dto"
|
"go-admin/common/dto"
|
||||||
@@ -9,6 +8,7 @@ import (
|
|||||||
orm "go-admin/common/global"
|
orm "go-admin/common/global"
|
||||||
{{ end }}
|
{{ end }}
|
||||||
"go-admin/common/models"
|
"go-admin/common/models"
|
||||||
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type {{.ClassName}} struct {
|
type {{.ClassName}} struct {
|
||||||
@@ -40,13 +40,13 @@ func (e *{{.ClassName}}) Generate() models.ActiveRecord {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e *{{.ClassName}}) GetId() interface{} {
|
func (e *{{.ClassName}}) GetId() interface{} {
|
||||||
return e.{{.PkGoField}}
|
return e.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *{{.ClassName}}) SetCreateBy(createBy uint) {
|
func (e *{{.ClassName}}) SetCreateBy(createBy uint) {
|
||||||
e.CreateBy = strconv.Itoa(int(createBy))
|
e.CreateBy = createBy
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *{{.ClassName}}) SetUpdateBy(updateBy uint) {
|
func (e *{{.ClassName}}) SetUpdateBy(updateBy uint) {
|
||||||
e.UpdateBy = strconv.Itoa(int(updateBy))
|
e.UpdateBy = updateBy
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user