package entities import ( "time" "github.com/google/uuid" "gorm.io/gorm" ) // UIComponent UI组件实体 type UIComponent struct { ID string `gorm:"primaryKey;type:varchar(36)" json:"id" comment:"组件ID"` ComponentCode string `gorm:"type:varchar(50);not null;uniqueIndex" json:"component_code" comment:"组件编码"` ComponentName string `gorm:"type:varchar(100);not null" json:"component_name" comment:"组件名称"` Description string `gorm:"type:text" json:"description" comment:"组件描述"` FilePath *string `gorm:"type:varchar(500)" json:"file_path" comment:"组件文件路径"` FileHash *string `gorm:"type:varchar(64)" json:"file_hash" comment:"文件哈希值"` FileSize *int64 `gorm:"type:bigint" json:"file_size" comment:"文件大小"` FileType *string `gorm:"type:varchar(50)" json:"file_type" comment:"文件类型"` FolderPath *string `gorm:"type:varchar(500)" json:"folder_path" comment:"组件文件夹路径"` IsExtracted bool `gorm:"default:false" json:"is_extracted" comment:"是否已解压"` Version string `gorm:"type:varchar(20)" json:"version" comment:"组件版本"` IsActive bool `gorm:"default:true" json:"is_active" comment:"是否启用"` SortOrder int `gorm:"default:0" json:"sort_order" comment:"排序"` CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at" comment:"创建时间"` UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at" comment:"更新时间"` DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at" comment:"软删除时间"` } func (UIComponent) TableName() string { return "ui_components" } func (u *UIComponent) BeforeCreate(tx *gorm.DB) error { if u.ID == "" { u.ID = uuid.New().String() } return nil }