2025-12-02 22:52:33 +08:00
|
|
|
|
package model
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
|
|
"gorm.io/gorm"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// BaseModel 基础模型
|
2025-12-26 01:15:17 +08:00
|
|
|
|
// @Description 通用基础模型(包含ID和时间戳字段)
|
2025-12-02 22:52:33 +08:00
|
|
|
|
// 包含 uint 类型的 ID 和标准时间字段,但时间字段不通过 JSON 返回给前端
|
|
|
|
|
|
type BaseModel struct {
|
|
|
|
|
|
// ID 主键
|
|
|
|
|
|
ID uint `gorm:"primarykey" json:"id"`
|
|
|
|
|
|
|
|
|
|
|
|
// CreatedAt 创建时间 (不返回给前端)
|
|
|
|
|
|
CreatedAt time.Time `gorm:"column:created_at" json:"-"`
|
|
|
|
|
|
|
|
|
|
|
|
// UpdatedAt 更新时间 (不返回给前端)
|
|
|
|
|
|
UpdatedAt time.Time `gorm:"column:updated_at" json:"-"`
|
|
|
|
|
|
|
|
|
|
|
|
// DeletedAt 删除时间 (软删除,不返回给前端)
|
|
|
|
|
|
DeletedAt gorm.DeletedAt `gorm:"index;column:deleted_at" json:"-"`
|
|
|
|
|
|
}
|