Files
platform/web/core/model.go

30 lines
570 B
Go
Raw Normal View History

package core
import (
"platform/pkg/u"
"time"
"gorm.io/gorm"
)
type IModel interface {
GetID() int32
}
type Model struct {
ID int32 `json:"id" gorm:"column:id;primaryKey"`
CreatedAt time.Time `json:"created_at" gorm:"column:created_at"`
UpdatedAt time.Time `json:"updated_at" gorm:"column:updated_at"`
DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"column:deleted_at"`
}
func (m *Model) GetID() int32 {
return m.ID
}
func GetIDs[T IModel](models []T) []int32 {
return u.Map(models, func(m T) int32 {
return m.GetID()
})
}