jinshan/pkg/util/baseModel.go
2025-06-19 10:35:26 +08:00

23 lines
886 B
Go

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