| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- package models
- import (
- {{- $bb := false -}}
- {{- range .Columns -}}
- {{- $z := .IsQuery -}}
- {{- if ($z) -}}
- {{- if eq .GoType "time.Time" -}}{{- $bb = true -}}{{- end -}}
- {{- end -}}
- {{- end -}}
- {{- range .Columns -}}
- {{- if eq .GoField "CreatedAt" -}}
- {{- else if eq .GoField "UpdatedAt" -}}
- {{- else if eq .GoField "DeletedAt" -}}
- {{- else -}}
- {{- if eq .GoType "time.Time" -}}{{- $bb = true -}}{{- end -}}
- {{- end -}}
- {{- end -}}
- {{- if eq $bb true }}
- "time"
- {{- end }}
- "IotAdmin/common/models"
- )
- // {{.ClassName}} {{.FunctionName}}实体
- type {{.ClassName}} struct {
- {{- range .Columns -}}
- {{$x := .Pk}}
- {{- if ($x) }}
- {{- if eq .GoField "Id" }}
- models.Model
- {{- else }}
- {{ $a := "" }}
- {{- if eq .GoType "int" -}}{{$a = "autoIncrement;"}}{{end -}}
- {{.GoField}} {{.GoType}} `json:"{{.JsonField}}" gorm:"type:{{.ColumnType}};primaryKey;{{$a}}comment:{{- if eq .ColumnComment "" -}}{{.GoField}}{{- else -}}{{.ColumnComment}}{{end -}}"` {{end -}}
- {{- 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.ControlBy
- models.ModelTime
- }
- func (*{{.ClassName}}) TableName() string {
- return "{{.TBName}}"
- }
- func (e *{{.ClassName}}) Generate() models.ActiveRecord {
- o := *e
- return &o
- }
- func (e *{{.ClassName}}) GetId() interface{} {
- return e.{{.PkGoField}}
- }
|