46 lines
2.0 KiB
Go
46 lines
2.0 KiB
Go
package models
|
|
|
|
import "gorm.io/gorm"
|
|
|
|
type TrainingData struct {
|
|
gorm.Model
|
|
Features string `gorm:"type:JSONB; not null" json:"features"`
|
|
Label string `gorm:"type:varchar(255)" json:"label"`
|
|
Probability float64 `gorm:"type:decimal(5,4)" json:"probability"`
|
|
SessionID string `gorm:"index" json:"session_id"`
|
|
}
|
|
|
|
// 对应Flutter的Belt结构
|
|
type Belt struct {
|
|
gorm.Model
|
|
Addr string `gorm:"uniqueIndex;size:255" json:"addr"` // 对应Dart的addr字段[6](@ref)
|
|
BID uint `gorm:"column:bid" json:"bid"` // 对应Dart的bid字段
|
|
Name string `gorm:"size:100" json:"name"`
|
|
}
|
|
|
|
// 对应Flutter的HeartRate结构
|
|
type HeartRate struct {
|
|
gorm.Model
|
|
TrainId uint `gorm:"column:train_id; index" json:"trainId"` // 外键关联训练记录[4](@ref)
|
|
BeltId uint `gorm:"column:belt_id;index" json:"bid"` // 对应Dart的bid字段
|
|
BeltAddr string `gorm:"column:belt_addr;size:255" json:"beltAddr"` // 对应Dart的beltAddr字段
|
|
Time int64 `gorm:"type:bigint" json:"time"` // 保持与前端一致的毫秒时间戳[3](@ref)
|
|
Value int `gorm:"type:int" json:"value"`
|
|
Identifier string `gorm:"uniqueIndex;type:varchar(255)" json:"identifier"`
|
|
}
|
|
|
|
// 对应Flutter的TrainRecord结构
|
|
type TrainRecord struct {
|
|
gorm.Model
|
|
TrainId uint `gorm:"uniqueIndex" json:"tid"` // 对应Dart的tid字段
|
|
StartTime int64 `gorm:"type:bigint" json:"time"` // 开始时间戳
|
|
EndTime int64 `gorm:"type:bigint" json:"endTime"` // 结束时间戳[3](@ref)
|
|
Name string `gorm:"size:100" json:"name"`
|
|
MaxHeartRate int `gorm:"type:int" json:"maxHeartRate"`
|
|
Duration int `gorm:"type:int" json:"duration"` // 持续时间(秒)
|
|
PeopleNum int `gorm:"type:int" json:"peopleNum"`
|
|
Evaluation string `gorm:"size:50" json:"evaluation"`
|
|
Belts []Belt `gorm:"many2many:train_record_belts;" json:"belts"` // 多对多关联[4](@ref)
|
|
HeartRates []HeartRate `gorm:"foreignKey:TrainId;references:TrainId" json:"heart_rates"`
|
|
}
|