base.go 776 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package common
  2. import "gorm.io/gorm"
  3. const (
  4. ModelPrefix = "ams_"
  5. SplittingSymbol = ","
  6. )
  7. // 自增长ID变更启始值 db.Exec("ALTER TABLE your_table_name AUTO_INCREMENT = 1000")
  8. type GormIdModel struct {
  9. ID int64 `json:"id" gorm:"primarykey;comment:id"`
  10. }
  11. type GormTimeModel struct {
  12. CreatedAt int64 `json:"created_at,omitempty" gorm:"autoCreateTime;comment:创建时间"`
  13. UpdatedAt int64 `json:"updated_at,omitempty" gorm:"autoUpdateTime;comment:更新时间"`
  14. }
  15. type GormDeleteModel struct {
  16. DeletedAt gorm.DeletedAt `gorm:"index;comment:删除时间"`
  17. }
  18. type GormBaseModel struct {
  19. GormIdModel
  20. GormTimeModel
  21. }
  22. type GormAllTimeModel struct {
  23. GormTimeModel
  24. GormDeleteModel
  25. }
  26. type GormFullModel struct {
  27. GormIdModel
  28. GormTimeModel
  29. GormDeleteModel
  30. }