probo/pkg/models/meta.go

39 lines
689 B
Go
Raw Normal View History

2023-09-22 10:29:10 +02:00
package models
import "time"
type Meta struct {
2023-10-28 20:50:06 +02:00
ID string `json:"id" yaml:"id" gorm:"primaryKey"`
2023-09-22 10:29:10 +02:00
CreatedAt time.Time `json:"created_at" yaml:"created_at"`
2023-10-28 20:50:06 +02:00
UpdatedAt time.Time `json:"updated_at" yaml:"updated_at"`
2023-12-17 18:56:20 +01:00
UniqueIDFunc func() string `json:"-" yaml:"-"`
2023-09-22 10:29:10 +02:00
}
2023-12-05 22:11:08 +01:00
func (m *Meta) GetID() string {
2023-12-17 18:56:20 +01:00
if m.UniqueIDFunc != nil {
return m.UniqueIDFunc()
}
2023-12-05 22:11:08 +01:00
return m.ID
}
func (m *Meta) SetID(id string) {
m.ID = id
}
func (m *Meta) SetCreatedAt(t time.Time) {
m.CreatedAt = t
}
func (m *Meta) SetUpdatedAt(t time.Time) {
m.UpdatedAt = t
}
func (m *Meta) GetCreatedAt() time.Time {
return m.CreatedAt
}
func (m *Meta) GetUpdatedAt() time.Time {
return m.UpdatedAt
}