1
This commit is contained in:
+12
-2
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"hepa-calc-api/api/model"
|
||||
"hepa-calc-api/utils"
|
||||
"time"
|
||||
)
|
||||
|
||||
// UserDto 用户表
|
||||
@@ -15,7 +16,7 @@ type UserDto struct {
|
||||
RegisterSource int `json:"register_source"` // 注册来源(1:app注册 2:公众号注册)
|
||||
OpenId string `json:"open_id"` // 用户微信标识
|
||||
UnionId string `json:"union_id"` // 微信开放平台标识
|
||||
Birthday *model.LocalTime `json:"birthday"` // 出生日期
|
||||
Birthday *string `json:"birthday"` // 出生日期
|
||||
Age *uint `json:"age"` // 年龄
|
||||
Sex *int `json:"sex"` // 性别(0:未知 1:男 2:女)
|
||||
Avatar string `json:"avatar"` // 头像
|
||||
@@ -35,7 +36,6 @@ func GetUserDto(m *model.User) *UserDto {
|
||||
Mobile: m.Mobile,
|
||||
UserStatus: m.UserStatus,
|
||||
RegisterSource: m.RegisterSource,
|
||||
Birthday: m.Birthday,
|
||||
Age: m.Age,
|
||||
Sex: m.Sex,
|
||||
Avatar: utils.AddOssDomain(m.Avatar),
|
||||
@@ -47,3 +47,13 @@ func GetUserDto(m *model.User) *UserDto {
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
// LoadBirthday 加载数据-生日
|
||||
func (r *UserDto) LoadBirthday(birthday *model.LocalTime) *UserDto {
|
||||
if birthday != nil {
|
||||
t := time.Time(*birthday).Format("2006-01-02")
|
||||
r.Birthday = &t
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hepa-calc-api/api/model"
|
||||
"time"
|
||||
)
|
||||
|
||||
// UserInfoDto 用户表-基础信息
|
||||
type UserInfoDto struct {
|
||||
UserInfoId string `json:"user_info_id"` // 主键id
|
||||
UserId string `json:"user_id"` // 用户id
|
||||
Height string `json:"height"` // 身高(cm)
|
||||
Weight string `json:"weight"` // 体重(kg)
|
||||
NationId string `json:"nation_id"` // 民族id
|
||||
IsFamilyHistory *int `json:"is_family_history"` // 是否存在家族病史(0:未知 1:是 2:否)
|
||||
IsPregnant *int `json:"is_pregnant"` // 是否怀孕(1:无计划 2:计划中 3:已怀孕 4:家有宝宝)
|
||||
ExpectedDate *string `json:"expected_date"` // 预产期
|
||||
ProvinceId *int `json:"province_id"` // 省份id
|
||||
Province string `json:"province"` // 省份
|
||||
CityId *int `json:"city_id"` // 城市id
|
||||
City string `json:"city"` // 城市
|
||||
CountyId *int `json:"county_id"` // 区县id
|
||||
County string `json:"county"` // 区县
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
}
|
||||
|
||||
// GetUserInfoDto 用户基础信息详情
|
||||
func GetUserInfoDto(m *model.UserInfo) *UserInfoDto {
|
||||
return &UserInfoDto{
|
||||
UserInfoId: fmt.Sprintf("%d", m.UserInfoId),
|
||||
UserId: fmt.Sprintf("%d", m.UserInfoId),
|
||||
Height: m.Height,
|
||||
Weight: m.Weight,
|
||||
NationId: fmt.Sprintf("%d", m.NationId),
|
||||
IsFamilyHistory: m.IsFamilyHistory,
|
||||
IsPregnant: m.IsPregnant,
|
||||
ProvinceId: m.ProvinceId,
|
||||
Province: m.Province,
|
||||
CityId: m.CityId,
|
||||
City: m.City,
|
||||
CountyId: m.CountyId,
|
||||
County: m.County,
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
// LoadExpectedDate 加载数据-预产期
|
||||
func (r *UserInfoDto) LoadExpectedDate(expectedDate *model.LocalTime) *UserInfoDto {
|
||||
if expectedDate != nil {
|
||||
t := time.Time(*expectedDate).Format("2006-01-02")
|
||||
r.ExpectedDate = &t
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
Reference in New Issue
Block a user