package models import ( "gorm.io/gorm" "time" ) // Gateway 代表一个物联网网关设备 type Gateway struct { ID uint `gorm:"primaryKey" json:"id"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` DeletedAt gorm.DeletedAt `gorm:"index" json:"-"` // MAC地址是网关的唯一标识 MAC string `gorm:"size:32;uniqueIndex;not null" json:"mac"` // 网关名称 Name string `gorm:"size:255" json:"name"` // 所属区域ID,用于关联幼儿园或区域 RegionID uint32 `gorm:"index" json:"regionId"` // 位置描述(如:一楼大厅、操场) Location string `gorm:"size:255" json:"location"` // 新增字段:是否已经售出 IsSold bool `json:"isSold"` ProjectType string `gorm:"size:255;default:'heartrate'" json:"projectType"` // 新增字段:售出时间 // 注意:使用 *time.Time 允许为空(未售出时为空) SoldAt *time.Time `json:"soldAt,omitempty"` // 是否启用 IsActive bool `json:"isActive"` } // TableName 指定数据库表名 func (Gateway) TableName() string { return "gateways" }