You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
894 B

  1. // 自动生成模板{{.StructName}}
  2. package model
  3. import (
  4. "github.com/jinzhu/gorm"
  5. )
  6. // 如果含有time.Time 请自行import time包
  7. type {{.StructName}} struct {
  8. gorm.Model {{- range .Fields}}
  9. {{- if eq .FieldType "bool" }}
  10. {{.FieldName}} *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:'{{.Comment}}'{{- if .DataType -}};type:{{.DataType}}{{- if .DataTypeLong -}}({{.DataTypeLong}}){{- end -}}{{- end -}}"`
  11. {{- else }}
  12. {{.FieldName}} {{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:'{{.Comment}}'{{- if .DataType -}};type:{{.DataType}}{{- if .DataTypeLong -}}({{.DataTypeLong}}){{- end -}}{{- end -}}"`
  13. {{- end }} {{- end }}
  14. }
  15. {{ if .TableName }}
  16. func ({{.StructName}}) TableName() string {
  17. return "{{.TableName}}"
  18. }
  19. {{ end }}