mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-10-04 06:22:02 +00:00
49 lines
1.3 KiB
Plaintext
49 lines
1.3 KiB
Plaintext
package models
|
|
|
|
import (
|
|
"strconv"
|
|
{{- if eq .IsActions true -}}
|
|
{{- else }}
|
|
"go-admin/common/dto"
|
|
"go-admin/tools"
|
|
orm "go-admin/common/global"
|
|
{{ end }}
|
|
"go-admin/common/models"
|
|
)
|
|
|
|
type {{.ClassName}} struct {
|
|
{{ range .Columns -}}
|
|
{{$x := .Pk}}
|
|
{{- if ($x) }}
|
|
{{.GoField}} {{.GoType}} `json:"{{.JsonField}}" gorm:"type:{{.ColumnType}};primary_key;AUTO_INCREMENT;comment:{{.ColumnComment}}"` // {{.ColumnComment}}
|
|
{{- else if eq .GoField "CreatedAt" -}}
|
|
{{- else if eq .GoField "UpdatedAt" -}}
|
|
{{- else if eq .GoField "DeletedAt" -}}
|
|
{{- else }}
|
|
{{.GoField}} {{.GoType}} `json:"{{.JsonField}}" gorm:"type:{{.ColumnType}};comment:{{.ColumnComment}}"` // {{.ColumnComment}}{{end -}}
|
|
{{- end }}
|
|
DataScope string `json:"dataScope" gorm:"-"`
|
|
Params string `json:"params" gorm:"-"`
|
|
BaseModel
|
|
}
|
|
|
|
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 = strconv.Itoa(int(createBy))
|
|
}
|
|
|
|
func (e *{{.ClassName}}) SetUpdateBy(updateBy uint) {
|
|
e.UpdateBy = strconv.Itoa(int(updateBy))
|
|
} |