Files
2026-05-01 07:46:48 +08:00

43 lines
1.1 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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"
}