2025-11-24 18:44:06 +08:00
|
|
|
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"`
|
2026-03-18 18:09:32 +08:00
|
|
|
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at"`
|
2025-11-24 18:44:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
})
|
|
|
|
|
}
|