model.go 502 B

123456789101112131415161718192021
  1. package models
  2. import (
  3. "fmt"
  4. "time"
  5. )
  6. // BaseModel 基础模型
  7. type BaseModel struct {
  8. ID uint `gorm:"column:id;primaryKey;autoIncrement;comment:主键ID" json:"id,omitempty"` // 主键ID
  9. }
  10. type CommonTimestampsField struct {
  11. CreatedAt time.Time `gorm:"column:created_at;index;" json:"created_at,omitempty"` // 创建时间
  12. UpdatedAt time.Time `gorm:"column:updated_at;index;" json:"updated_at,omitempty"` // 更新时间
  13. }
  14. func GetStringID(id uint) string {
  15. return fmt.Sprintf("%d", id)
  16. }