44 lines
1.8 KiB
Go
44 lines
1.8 KiB
Go
package model
|
||
|
||
import (
|
||
"gorm.io/gorm"
|
||
"hepa-calc-admin-api/global"
|
||
"time"
|
||
)
|
||
|
||
// UserInfo 用户表-基础信息
|
||
type UserInfo struct {
|
||
UserInfoId int64 `gorm:"column:user_info_id;type:bigint(19);primary_key;comment:主键id" json:"user_info_id"`
|
||
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:用户id" json:"user_id"`
|
||
Height string `gorm:"column:height;type:varchar(20);comment:身高(cm)" json:"height"`
|
||
Weight string `gorm:"column:weight;type:varchar(20);comment:体重(kg)" json:"weight"`
|
||
NationId int64 `gorm:"column:nation_id;type:bigint(19);comment:民族id" json:"nation_id"`
|
||
FamilyHistoryId int64 `gorm:"column:family_history_id;type:bigint(19);comment:家族病史id" json:"family_history_id"`
|
||
ProvinceId int `gorm:"column:province_id;type:int(11);comment:省份id" json:"province_id"`
|
||
Province string `gorm:"column:province;type:varchar(40);comment:省份" json:"province"`
|
||
CityId int `gorm:"column:city_id;type:int(11);comment:城市id" json:"city_id"`
|
||
City string `gorm:"column:city;type:varchar(50);comment:城市" json:"city"`
|
||
CountyId int `gorm:"column:county_id;type:int(11);comment:区县id" json:"county_id"`
|
||
County string `gorm:"column:county;type:varchar(255);comment:区县" json:"county"`
|
||
DiseaseClassId int64 `gorm:"column:disease_class_id;type:bigint(19);comment:疾病分类id" json:"disease_class_id"`
|
||
Model
|
||
}
|
||
|
||
func (m *UserInfo) TableName() string {
|
||
return "user_info"
|
||
}
|
||
|
||
func (m *UserInfo) BeforeCreate(tx *gorm.DB) error {
|
||
if m.UserInfoId == 0 {
|
||
m.UserInfoId = global.Snowflake.Generate().Int64()
|
||
}
|
||
|
||
m.CreatedAt = LocalTime(time.Now())
|
||
tx.Statement.SetColumn("CreatedAt", m.CreatedAt)
|
||
|
||
m.UpdatedAt = LocalTime(time.Now())
|
||
tx.Statement.SetColumn("UpdatedAt", m.UpdatedAt)
|
||
|
||
return nil
|
||
}
|