mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-22 02:27:57 +00:00
54 lines
1.2 KiB
Plaintext
54 lines
1.2 KiB
Plaintext
package models
|
|
|
|
import (
|
|
"gorm.io/gorm"
|
|
|
|
{{- if eq .IsActions 2 -}}
|
|
|
|
"go-admin/common/dto"
|
|
"go-admin/tools"
|
|
orm "go-admin/common/global"
|
|
{{ end }}
|
|
"go-admin/common/models"
|
|
)
|
|
|
|
type {{.ClassName}} struct {
|
|
gorm.Model
|
|
models.ControlBy
|
|
{{ 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 }}
|
|
DataScope string `json:"dataScope" gorm:"-"`
|
|
Params string `json:"params" gorm:"-"`
|
|
}
|
|
|
|
func ({{.ClassName}}) TableName() string {
|
|
return "{{.TBName}}"
|
|
}
|
|
|
|
func (e *{{.ClassName}}) Generate() models.ActiveRecord {
|
|
o := *e
|
|
return &o
|
|
}
|
|
|
|
func (e *{{.ClassName}}) GetId() interface{} {
|
|
return e.{{.PkGoField}}
|
|
}
|
|
|
|
func (e *{{.ClassName}}) SetCreateBy(createBy uint) {
|
|
e.CreateBy = createBy
|
|
}
|
|
|
|
func (e *{{.ClassName}}) SetUpdateBy(updateBy uint) {
|
|
e.UpdateBy = updateBy
|
|
}
|