新增了获取用户数据-详情信息,获取用户数据-病例。修改了获取用户列表-基本信息-分页,用户信息是否完善字段

This commit is contained in:
2024-08-26 11:32:18 +08:00
parent d5881671af
commit 87bcb6e755
17 changed files with 731 additions and 26 deletions
+17 -6
View File
@@ -16,7 +16,7 @@ type UserDto struct {
OpenId string `json:"open_id"` // 用户微信标识
UnionId string `json:"union_id"` // 微信开放平台标识
Age *uint `json:"age"` // 年龄
Sex uint `json:"sex"` // 性别(0:未知 1:男 2:女)
Sex *int `json:"sex"` // 性别(0:未知 1:男 2:女)
Avatar string `json:"avatar"` // 头像
IsMember int `json:"is_member"` // 是否会员(0:否 1:是)
MemberExpireDate *model.LocalTime `json:"member_expire_date"` // 会员到期时间(非会员时为null)
@@ -27,7 +27,7 @@ type UserDto struct {
LoginIp string `json:"login_ip"` // 登陆ip
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
IsInfoComplete int `json:"is_info_complete"` // 信息完善状态 0:否 1:是
IsInfoComplete bool `json:"is_info_complete"` // 信息完善状态 0:否 1:是
}
// GetUserListDto 列表
@@ -44,7 +44,7 @@ func GetUserListDto(m []*model.User) []*UserDto {
UserStatus: v.UserStatus,
RegisterSource: v.RegisterSource,
Age: v.Age,
Sex: uint(v.Sex),
Sex: &v.Sex,
Avatar: utils.AddOssDomain(v.Avatar),
IsMember: v.IsMember,
MemberExpireDate: v.MemberExpireDate,
@@ -79,7 +79,7 @@ func GetUserDto(m *model.User) *UserDto {
UserStatus: m.UserStatus,
RegisterSource: m.RegisterSource,
Age: m.Age,
Sex: uint(m.Sex),
Sex: &m.Sex,
Avatar: utils.AddOssDomain(m.Avatar),
IsMember: m.IsMember,
MemberExpireDate: m.MemberExpireDate,
@@ -95,10 +95,21 @@ func GetUserDto(m *model.User) *UserDto {
// LoadIsInfoComplete 加载信息完善状态
func (r *UserDto) LoadIsInfoComplete(m *model.UserInfo) *UserDto {
isCompleteInfo := false
if m != nil {
if m.DiseaseClassId != 0 && m.FamilyHistoryId != 0 {
r.IsInfoComplete = 1
if m.Height == "" {
isCompleteInfo = false
} else if m.Weight == "" {
isCompleteInfo = false
} else if m.IsFamilyHistory == nil {
isCompleteInfo = false
} else if m.ProvinceId == "" {
isCompleteInfo = false
} else {
isCompleteInfo = true
}
}
r.IsInfoComplete = isCompleteInfo
return r
}
+48
View File
@@ -0,0 +1,48 @@
package dto
import (
"fmt"
"hepa-calc-admin-api/api/model"
)
// UserCaseDto 用户表-病例
type UserCaseDto struct {
UserCaseId string `json:"user_case_id"` // 主键id
UserId string `json:"user_id"` // 用户id
IsHospital *int `json:"is_hospital"` // 是否医院就诊(0:否 1:是)
LiverStatus string `json:"liver_status"` // 肝脏状态
IsMedication *int `json:"is_medication"` // 是否服药(0:否 1:是)
Medication string `json:"medication"` // 服药名称
ChronicDisease string `json:"chronic_disease"` // 慢性疾病名称(逗号分隔)
IsAllergyHistory *int `json:"is_allergy_history"` // 过敏史(0:否 1:是)
AllergyHistory string `json:"allergy_history"` // 过敏史描述
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
UserCaseDiseaseItem []*UserCaseDiseaseItemDto `json:"user_case_disease_item"` // 所患疾病列表
}
// GetUserCaseDto 详情
func GetUserCaseDto(m *model.UserCase) *UserCaseDto {
return &UserCaseDto{
UserCaseId: fmt.Sprintf("%d", m.UserCaseId),
UserId: fmt.Sprintf("%d", m.UserId),
IsHospital: m.IsHospital,
LiverStatus: m.LiverStatus,
IsMedication: m.IsMedication,
Medication: m.Medication,
ChronicDisease: m.ChronicDisease,
IsAllergyHistory: m.IsAllergyHistory,
AllergyHistory: m.AllergyHistory,
CreatedAt: m.CreatedAt,
UpdatedAt: m.UpdatedAt,
}
}
// LoadUserCaseDiseaseItem 加载数据-疾病列表
func (r *UserCaseDto) LoadUserCaseDiseaseItem(m []*model.UserCaseDiseaseItem) *UserCaseDto {
if len(m) > 0 {
r.UserCaseDiseaseItem = GetUserCaseDiseaseItemListDto(m)
}
return r
}
+59
View File
@@ -0,0 +1,59 @@
package dto
import (
"fmt"
"hepa-calc-admin-api/api/model"
)
// UserCaseDiseaseItemDto 用户-病例-所患疾病列表
type UserCaseDiseaseItemDto struct {
ItemId string `json:"item_id"` // 主键id
UserCaseId string `json:"user_case_id"` // 用户病例id
DiseaseClassId string `json:"disease_class_id"` // 疾病分类id
DiseaseClassName string `json:"disease_class_name"` // 疾病分类名称
AppIden string `json:"app_iden"` // app唯一标识
Duration *int `json:"duration"` // 患病时长(年)
Genotype string `json:"genotype"` // 基因型(仅丙肝存在)
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
}
// GetUserCaseDiseaseItemListDto 列表-分页
func GetUserCaseDiseaseItemListDto(m []*model.UserCaseDiseaseItem) []*UserCaseDiseaseItemDto {
// 处理返回值
responses := make([]*UserCaseDiseaseItemDto, len(m))
if len(m) > 0 {
for i, v := range m {
response := &UserCaseDiseaseItemDto{
ItemId: fmt.Sprintf("%d", v.ItemId),
UserCaseId: fmt.Sprintf("%d", v.UserCaseId),
DiseaseClassId: fmt.Sprintf("%d", v.DiseaseClassId),
AppIden: v.AppIden,
Duration: v.Duration,
Genotype: v.Genotype,
CreatedAt: v.CreatedAt,
UpdatedAt: v.UpdatedAt,
}
// 加载数据-疾病名称
if v.BaseDiseaseClass != nil {
response = response.LoadDiseaseClassName(v.BaseDiseaseClass)
}
// 将转换后的结构体添加到新切片中
responses[i] = response
}
}
return responses
}
// LoadDiseaseClassName 加载数据-疾病名称
func (r *UserCaseDiseaseItemDto) LoadDiseaseClassName(m *model.BaseDiseaseClass) *UserCaseDiseaseItemDto {
if m != nil {
r.DiseaseClassName = m.DiseaseClassName
}
return r
}
+64
View File
@@ -0,0 +1,64 @@
package dto
import (
"fmt"
"hepa-calc-admin-api/api/model"
"time"
)
// UserInfoDto 用户表-基础信息
type UserInfoDto struct {
UserInfoId string `json:"user_info_id"` // 主键id
UserId string `json:"user_id"` // 用户id
Height *float64 `json:"height"` // 身高(cm
Weight *float64 `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 string `json:"province_id"` // 省份id
Province string `json:"province"` // 省份
CityId string `json:"city_id"` // 城市id
City string `json:"city"` // 城市
CountyId string `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),
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
}
// LoadNationId 加载数据-民族
func (r *UserInfoDto) LoadNationId(nationId *int64) *UserInfoDto {
if nationId != nil {
r.NationId = fmt.Sprintf("%d", *nationId)
}
return r
}