healthapp
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

64 lines
2.4 KiB

package model
import (
"time"
"gorm.io/gorm"
)
// User 用户表
type User struct {
gorm.Model
Phone string `gorm:"uniqueIndex;size:20" json:"phone"`
Email string `gorm:"uniqueIndex;size:100" json:"email"`
PasswordHash string `gorm:"size:255" json:"-"`
Nickname string `gorm:"size:50" json:"nickname"`
Avatar string `gorm:"size:255" json:"avatar"`
SurveyCompleted bool `gorm:"default:false" json:"survey_completed"`
}
// HealthProfile 健康档案
type HealthProfile struct {
gorm.Model
UserID uint `gorm:"uniqueIndex" json:"user_id"`
Name string `gorm:"size:50" json:"name"`
BirthDate *time.Time `json:"birth_date"`
Gender string `gorm:"size:10" json:"gender"` // male, female
Height float64 `json:"height"` // cm
Weight float64 `json:"weight"` // kg
BMI float64 `json:"bmi"`
BloodType string `gorm:"size:10" json:"blood_type"` // A, B, AB, O
Occupation string `gorm:"size:50" json:"occupation"`
MaritalStatus string `gorm:"size:20" json:"marital_status"` // single, married, divorced
Region string `gorm:"size:100" json:"region"`
}
// LifestyleInfo 生活习惯
type LifestyleInfo struct {
gorm.Model
UserID uint `gorm:"uniqueIndex" json:"user_id"`
SleepTime string `gorm:"size:10" json:"sleep_time"` // HH:MM
WakeTime string `gorm:"size:10" json:"wake_time"` // HH:MM
SleepQuality string `gorm:"size:20" json:"sleep_quality"` // good, normal, poor
MealRegularity string `gorm:"size:20" json:"meal_regularity"` // regular, irregular
DietPreference string `gorm:"size:50" json:"diet_preference"` // 偏好
DailyWaterML int `json:"daily_water_ml"` // 每日饮水量 ml
ExerciseFrequency string `gorm:"size:20" json:"exercise_frequency"` // never, sometimes, often, daily
ExerciseType string `gorm:"size:100" json:"exercise_type"`
ExerciseDurationMin int `json:"exercise_duration_min"` // 每次运动时长
IsSmoker bool `json:"is_smoker"`
AlcoholFrequency string `gorm:"size:20" json:"alcohol_frequency"` // never, sometimes, often
}
// TableName 指定表名
func (User) TableName() string {
return "users"
}
func (HealthProfile) TableName() string {
return "health_profiles"
}
func (LifestyleInfo) TableName() string {
return "lifestyle_infos"
}