Files
PandaX/resource/template/go/entity.template
2022-07-16 18:49:57 +08:00

25 lines
1.2 KiB
Plaintext

// ==========================================================================
// 生成日期:{{.CreatedAt}}
// 生成路径: apps/{{.PackageName}}/entity/{{.TableName}}.go
// 生成人:{{.FunctionAuthor}}
// ==========================================================================
package entity
{{$hasGTime:=false}}
{{- range $index, $column := .Columns -}}
{{- if eq $column.GoType "Time" -}}
{{$hasGTime = true}}
{{- end -}}
{{- end -}}
{{if $hasGTime -}}import "time"{{- end }}
type {{.ClassName}} struct {
{{range $index, $column := .Columns}}
{{if eq $column.IsPk "1"}} {{$column.GoField}} {{if eq $column.GoType "Time"}}time.Time{{else}}{{$column.GoType}}{{end}} `gorm:"primary_key;{{if eq $column.IsIncrement "1"}}AUTO_INCREMENT{{end}}" json:"{{$column.JsonField}}"` // {{$column.ColumnComment}} {{else}} {{$column.GoField}} {{if eq $column.GoType "Time"}}time.Time{{else}}{{$column.GoType}}{{end}} `gorm:"{{$column.ColumnName}};type:{{$column.ColumnType}};comment:{{$column.ColumnComment}}" json:"{{$column.JsonField}}" {{if eq $column.IsRequired "1"}}binding:"required"{{end}}` // {{$column.ColumnComment}} {{end}}
{{end}}
}
func ({{.ClassName}}) TableName() string {
return "{{.TableName}}"
}