69 lines
2.9 KiB
Go
69 lines
2.9 KiB
Go
package models
|
|
|
|
import "gorm.io/gorm"
|
|
|
|
type StepStrideFreq struct {
|
|
gorm.Model
|
|
TrainId uint `gorm:"column:train_id; index" json:"trainId"` // 外键关联训练记录[4](@ref)
|
|
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的HeartRate结构
|
|
type StepHeartRate struct {
|
|
gorm.Model
|
|
TrainId uint `gorm:"column:train_id; index" json:"trainId"` // 外键关联训练记录[4](@ref)
|
|
Time int64 `gorm:"type:bigint" json:"time"` // 保持与前端一致的毫秒时间戳[3](@ref)
|
|
Value int `gorm:"type:int" json:"value"`
|
|
HeartRateType int `gorm:"type:int" json:"predictValue"`
|
|
Identifier string `gorm:"uniqueIndex;type:varchar(255)" json:"identifier"`
|
|
}
|
|
|
|
// 对应Flutter的TrainRecord结构
|
|
type StepTrainRecord 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"` // 持续时间(秒)
|
|
DeadZone int `gorm:"type:int" json:"deadZone"`
|
|
Evaluation string `gorm:"size:50" json:"evaluation"`
|
|
HeartRates []StepHeartRate `gorm:"foreignKey:TrainId;references:TrainId" json:"heartRates"`
|
|
StrideFreqs []StepStrideFreq `gorm:"foreignKey:TrainId;references:TrainId" json:"strideFreqs"`
|
|
}
|
|
|
|
type RegressionType int
|
|
|
|
const (
|
|
LinearRegression RegressionType = iota + 1
|
|
LogarithmicRegression
|
|
QuadraticRegression
|
|
)
|
|
|
|
type RegressionResult struct {
|
|
gorm.Model
|
|
RegressionType RegressionType `gorm:"column:regression_type;index" json:"regressionType"` // 训练记录ID
|
|
TrainId uint `gorm:"column:train_id;index" json:"trainId"` // 训练记录ID
|
|
Equation string `gorm:"type:text" json:"equation"` // 回归方程
|
|
|
|
// 线性回归系数
|
|
Slope *float64 `gorm:"column:slope" json:"slope"`
|
|
Intercept *float64 `gorm:"column:intercept" json:"intercept"`
|
|
|
|
// 对数回归系数
|
|
LogA *float64 `gorm:"column:log_a" json:"logA"`
|
|
LogB *float64 `gorm:"column:log_b" json:"logB"`
|
|
|
|
// 二次回归系数
|
|
QuadraticA *float64 `gorm:"column:quadratic_a" json:"quadraticA"`
|
|
QuadraticB *float64 `gorm:"column:quadratic_b" json:"quadraticB"`
|
|
QuadraticC *float64 `gorm:"column:quadratic_c" json:"quadraticC"`
|
|
|
|
RSquared *float64 `gorm:"column:r_squared" json:"rSquared"` // R平方值
|
|
}
|