- 新增迁移 000090:tb_device 扩展 5 个 Gateway sync-info 字段(online_status / last_online_time / software_version / switch_mode / last_gateway_sync_at) - 新增迁移 000091:tb_device_sim_binding 新增 is_current 字段(当前使用卡标识) - 更新 Device 模型新增对应 5 个字段 - 更新 DeviceSimBinding 模型新增 IsCurrent 字段
26 lines
1.2 KiB
Go
26 lines
1.2 KiB
Go
package model
|
||
|
||
import (
|
||
"time"
|
||
|
||
"gorm.io/gorm"
|
||
)
|
||
|
||
// DeviceSimBinding 设备-IoT卡绑定关系模型
|
||
// 管理设备与 IoT 卡的多对多绑定关系(1 设备绑定 1-4 张 IoT 卡)
|
||
type DeviceSimBinding struct {
|
||
gorm.Model
|
||
BaseModel `gorm:"embedded"`
|
||
DeviceID uint `gorm:"column:device_id;index:idx_device_slot;not null;comment:设备ID" json:"device_id"`
|
||
IotCardID uint `gorm:"column:iot_card_id;index;not null;comment:IoT卡ID" json:"iot_card_id"`
|
||
SlotPosition int `gorm:"column:slot_position;type:int;index:idx_device_slot;comment:插槽位置(1, 2, 3, 4)" json:"slot_position"`
|
||
BindStatus int `gorm:"column:bind_status;type:int;default:1;comment:绑定状态 1-已绑定 2-已解绑" json:"bind_status"`
|
||
BindTime *time.Time `gorm:"column:bind_time;comment:绑定时间" json:"bind_time"`
|
||
UnbindTime *time.Time `gorm:"column:unbind_time;comment:解绑时间" json:"unbind_time"`
|
||
IsCurrent bool `gorm:"column:is_current;type:boolean;not null;default:false;comment:是否为当前使用的卡(同一设备同一时刻最多一条为 true)" json:"is_current"`
|
||
}
|
||
|
||
func (DeviceSimBinding) TableName() string {
|
||
return "tb_device_sim_binding"
|
||
}
|