meta.go 689 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package models
  2. import "time"
  3. type Meta struct {
  4. ID string `json:"id" yaml:"id" gorm:"primaryKey"`
  5. CreatedAt time.Time `json:"created_at" yaml:"created_at"`
  6. UpdatedAt time.Time `json:"updated_at" yaml:"updated_at"`
  7. UniqueIDFunc func() string `json:"-" yaml:"-"`
  8. }
  9. func (m *Meta) GetID() string {
  10. if m.UniqueIDFunc != nil {
  11. return m.UniqueIDFunc()
  12. }
  13. return m.ID
  14. }
  15. func (m *Meta) SetID(id string) {
  16. m.ID = id
  17. }
  18. func (m *Meta) SetCreatedAt(t time.Time) {
  19. m.CreatedAt = t
  20. }
  21. func (m *Meta) SetUpdatedAt(t time.Time) {
  22. m.UpdatedAt = t
  23. }
  24. func (m *Meta) GetCreatedAt() time.Time {
  25. return m.CreatedAt
  26. }
  27. func (m *Meta) GetUpdatedAt() time.Time {
  28. return m.UpdatedAt
  29. }