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"` } // 分析结果存储实体 type BeltAnalysis struct { gorm.Model TrainID uint `gorm:"index;not null"` // 关联训练记录 BeltID uint `gorm:"index;not null"` // 腰带唯一标识 RunType string `gorm:"size:100" json:"RunType"` Avg2min float64 `gorm:"type:double precision"` // 第2分钟平均心率 Avg4min float64 `gorm:"type:double precision"` // 第4分钟平均心率 Avg6min float64 `gorm:"type:double precision"` // 第6分钟平均心率 CurveParamA float64 `gorm:"type:double precision"` // 拟合参数a值 } // 中间计算结构(无需持久化) // 对应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"` PredictValue int `gorm:"type:int" json:"predictValue"` 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"` RunType string `gorm:"size:100" json:"RunType"` 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"` }