model.go.tpl 1.0 KB

123456789101112131415161718192021222324252627
  1. // 自动生成模板{{.StructName}}
  2. package {{.Package}}
  3. import (
  4. "log-server/global"
  5. {{ if .HasTimer }}"time"{{ end }}
  6. )
  7. // {{.StructName}} 结构体
  8. type {{.StructName}} struct {
  9. global.GVA_MODEL {{- range .Fields}}
  10. {{- if eq .FieldType "enum" }}
  11. {{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};type:enum({{.DataTypeLong}});comment:{{.Comment}};"`
  12. {{- else if ne .FieldType "string" }}
  13. {{.FieldName}} *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}"`
  14. {{- else }}
  15. {{.FieldName}} {{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}"`
  16. {{- end }} {{- end }}
  17. }
  18. {{ if .TableName }}
  19. // TableName {{.StructName}} 表名
  20. func ({{.StructName}}) TableName() string {
  21. return "{{.TableName}}"
  22. }
  23. {{ end }}