Files
go-admin/template/v4/model.go.template
T
2021-03-11 14:56:15 +08:00

37 lines
886 B
Plaintext

package models
import (
// "gorm.io/gorm"
"go-admin/common/models"
)
type {{.ClassName}} struct {
models.Model
{{ range .Columns -}}
{{$x := .Pk}}
{{- if ($x) }}
{{- 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}}" gorm:"type:{{.ColumnType}};comment:{{- if eq .ColumnComment "" -}}{{.GoField}}{{- else -}}{{.ColumnComment}}{{end -}}"` {{end -}}
{{- end }}
models.ModelTime
models.ControlBy
}
func ({{.ClassName}}) TableName() string {
return "{{.TBName}}"
}
func (e *{{.ClassName}}) Generate() models.ActiveRecord {
o := *e
return &o
}
func (e *{{.ClassName}}) GetId() interface{} {
return e.{{.PkGoField}}
}