haibei/pkg/util/baseModel.go
2025-06-19 10:33:58 +08:00

24 lines
795 B
Go

package util
import (
"time"
"gorm.io/plugin/soft_delete"
)
type BaseModel struct {
ID uint `json:"id" gorm:"primaryKey"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt soft_delete.DeletedAt `json:"deletedAt" gorm:"index" `
CreatedID uint `json:"createdId" gorm:"column:created_id;index;comment:创建人ID"`
DeletedID uint `json:"deletedId" gorm:"column:deleted_id;index;comment:删除人ID"`
}
type BaseModelWithoutDeletedAt struct {
ID uint `json:"id" gorm:"primaryKey"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
CreatedID uint `json:"createdId" gorm:"column:created_id;index;comment:创建人ID"`
}