修改了手机号登录
This commit is contained in:
+218
-13
@@ -169,7 +169,7 @@ func (r *UserService) HandleAppUserInfo(tx *gorm.DB, user *model.User, userInfo
|
||||
// 出生日期/年龄
|
||||
if appUserInfo.Data.Birthday != "" {
|
||||
if user.Birthday != nil {
|
||||
birthday := time.Time(*user.Birthday).Format("2006-01-02 15:04:05")
|
||||
birthday := time.Time(*user.Birthday).Format("2006-01-02")
|
||||
if appUserInfo.Data.Birthday != birthday {
|
||||
userData["birthday"] = appUserInfo.Data.Birthday
|
||||
}
|
||||
@@ -213,8 +213,8 @@ func (r *UserService) HandleAppUserInfo(tx *gorm.DB, user *model.User, userInfo
|
||||
}
|
||||
|
||||
// 体重
|
||||
if appUserInfo.Data.Weight != nil {
|
||||
weight := fmt.Sprintf("%f", appUserInfo.Data.Weight)
|
||||
if appUserInfo.Data.Weight != nil && *appUserInfo.Data.Weight != 0 {
|
||||
weight := fmt.Sprintf("%d", *appUserInfo.Data.Weight)
|
||||
|
||||
if userInfo.Weight != "" {
|
||||
if weight != userInfo.Weight {
|
||||
@@ -225,6 +225,19 @@ func (r *UserService) HandleAppUserInfo(tx *gorm.DB, user *model.User, userInfo
|
||||
}
|
||||
}
|
||||
|
||||
// 身高
|
||||
if appUserInfo.Data.Height != nil && *appUserInfo.Data.Height != 0 {
|
||||
height := fmt.Sprintf("%d", *appUserInfo.Data.Height)
|
||||
|
||||
if userInfo.Height != "" {
|
||||
if height != userInfo.Height {
|
||||
userInfoData["height"] = height
|
||||
}
|
||||
} else {
|
||||
userInfoData["height"] = height
|
||||
}
|
||||
}
|
||||
|
||||
// 省份 id
|
||||
if appUserInfo.Data.ProvinceID != nil {
|
||||
// 获取省份数据
|
||||
@@ -237,7 +250,7 @@ func (r *UserService) HandleAppUserInfo(tx *gorm.DB, user *model.User, userInfo
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
userInfoData["province_name"] = baseArea.Name
|
||||
userInfoData["province"] = baseArea.Name
|
||||
}
|
||||
} else {
|
||||
userInfoData["province_id"] = appUserInfo.Data.ProvinceID
|
||||
@@ -246,7 +259,7 @@ func (r *UserService) HandleAppUserInfo(tx *gorm.DB, user *model.User, userInfo
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
userInfoData["province_name"] = baseArea.Name
|
||||
userInfoData["province"] = baseArea.Name
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,20 +271,20 @@ func (r *UserService) HandleAppUserInfo(tx *gorm.DB, user *model.User, userInfo
|
||||
if *appUserInfo.Data.CityID != *userInfo.CityId {
|
||||
userInfoData["city_id"] = appUserInfo.Data.CityID
|
||||
|
||||
baseArea, err := baseAreaDao.GetBaseAreaById(int64(*appUserInfo.Data.ProvinceID))
|
||||
baseArea, err := baseAreaDao.GetBaseAreaById(int64(*appUserInfo.Data.CityID))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
userInfoData["city_name"] = baseArea.Name
|
||||
userInfoData["city"] = baseArea.Name
|
||||
}
|
||||
} else {
|
||||
userInfoData["city_id"] = appUserInfo.Data.CityID
|
||||
|
||||
baseArea, err := baseAreaDao.GetBaseAreaById(int64(*appUserInfo.Data.ProvinceID))
|
||||
baseArea, err := baseAreaDao.GetBaseAreaById(int64(*appUserInfo.Data.CityID))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
userInfoData["city_name"] = baseArea.Name
|
||||
userInfoData["city"] = baseArea.Name
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,20 +296,20 @@ func (r *UserService) HandleAppUserInfo(tx *gorm.DB, user *model.User, userInfo
|
||||
if *appUserInfo.Data.CountyID != *userInfo.CountyId {
|
||||
userInfoData["county_id"] = appUserInfo.Data.CountyID
|
||||
|
||||
baseArea, err := baseAreaDao.GetBaseAreaById(int64(*appUserInfo.Data.ProvinceID))
|
||||
baseArea, err := baseAreaDao.GetBaseAreaById(int64(*appUserInfo.Data.CountyID))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
userInfoData["county_name"] = baseArea.Name
|
||||
userInfoData["county"] = baseArea.Name
|
||||
}
|
||||
} else {
|
||||
userInfoData["county_id"] = appUserInfo.Data.CountyID
|
||||
|
||||
baseArea, err := baseAreaDao.GetBaseAreaById(int64(*appUserInfo.Data.ProvinceID))
|
||||
baseArea, err := baseAreaDao.GetBaseAreaById(int64(*appUserInfo.Data.CountyID))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
userInfoData["county_name"] = baseArea.Name
|
||||
userInfoData["county"] = baseArea.Name
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,3 +395,195 @@ func (r *UserService) HandleAppUserInfo(tx *gorm.DB, user *model.User, userInfo
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// HandleAppUserCase 处理app用户病例数据
|
||||
func (r *UserService) HandleAppUserCase(tx *gorm.DB, user *model.User) error {
|
||||
appUserCase, err := app.GetUserCaseByAppIden(user.AppIden)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 用户无病例数据
|
||||
if appUserCase.Data == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// 获取用户病例数据
|
||||
userCaseDao := dao.UserCaseDao{}
|
||||
userCase, _ := userCaseDao.GetUserCaseByUserId(user.UserId)
|
||||
if userCase == nil {
|
||||
// 未添加用户病例数据
|
||||
userCase = &model.UserCase{}
|
||||
userCase.UserId = user.UserId
|
||||
|
||||
// 是否过敏史
|
||||
if appUserCase.Data.IsAllergy != nil {
|
||||
userCase.IsAllergyHistory = appUserCase.Data.IsAllergy
|
||||
|
||||
// 过敏史描述
|
||||
if appUserCase.Data.AllergyInfo != "" {
|
||||
userCase.AllergyHistory = appUserCase.Data.AllergyInfo
|
||||
}
|
||||
}
|
||||
|
||||
// 是否服药
|
||||
if appUserCase.Data.IsMedication != nil {
|
||||
userCase.IsMedication = appUserCase.Data.IsMedication
|
||||
|
||||
// 服药名称
|
||||
if appUserCase.Data.MedicationInfo != "" {
|
||||
userCase.Medication = appUserCase.Data.MedicationInfo
|
||||
}
|
||||
}
|
||||
|
||||
// 是否去医院
|
||||
if appUserCase.Data.IsHospital != nil {
|
||||
userCase.IsHospital = appUserCase.Data.IsHospital
|
||||
}
|
||||
|
||||
// 慢性疾病
|
||||
if appUserCase.Data.OtherDisease != "" {
|
||||
userCase.ChronicDisease = appUserCase.Data.OtherDisease
|
||||
}
|
||||
|
||||
// 目前肝脏状态
|
||||
if appUserCase.Data.LiverStatus != "" {
|
||||
userCase.LiverStatus = appUserCase.Data.LiverStatus
|
||||
}
|
||||
|
||||
userCase, err = userCaseDao.AddUserCase(tx, userCase)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
// 对比处理用户数据
|
||||
userCaseData := make(map[string]interface{}) // 用户病例数据
|
||||
|
||||
// 是否过敏史
|
||||
if appUserCase.Data.IsAllergy != nil {
|
||||
if userCase.IsAllergyHistory != nil {
|
||||
if *appUserCase.Data.IsAllergy != *userCase.IsAllergyHistory {
|
||||
userCaseData["is_allergy_history"] = appUserCase.Data.IsAllergy
|
||||
}
|
||||
} else {
|
||||
userCaseData["is_allergy_history"] = appUserCase.Data.IsAllergy
|
||||
}
|
||||
|
||||
// 过敏史描述
|
||||
if appUserCase.Data.AllergyInfo != "" {
|
||||
if userCase.AllergyHistory != "" {
|
||||
if appUserCase.Data.AllergyInfo != userCase.AllergyHistory {
|
||||
userCaseData["allergy_history"] = appUserCase.Data.AllergyInfo
|
||||
}
|
||||
} else {
|
||||
userCaseData["allergy_history"] = appUserCase.Data.AllergyInfo
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 是否服药
|
||||
if appUserCase.Data.IsMedication != nil {
|
||||
if userCase.IsMedication != nil {
|
||||
if *appUserCase.Data.IsMedication != *userCase.IsMedication {
|
||||
userCaseData["is_medication"] = appUserCase.Data.IsMedication
|
||||
}
|
||||
} else {
|
||||
userCaseData["is_medication"] = appUserCase.Data.IsMedication
|
||||
}
|
||||
|
||||
// 服药名称
|
||||
if appUserCase.Data.MedicationInfo != "" {
|
||||
if userCase.Medication != "" {
|
||||
if appUserCase.Data.MedicationInfo != userCase.Medication {
|
||||
userCaseData["medication"] = appUserCase.Data.MedicationInfo
|
||||
}
|
||||
} else {
|
||||
userCaseData["medication"] = appUserCase.Data.MedicationInfo
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 是否去医院
|
||||
if appUserCase.Data.IsHospital != nil {
|
||||
if userCase.IsHospital != nil {
|
||||
if *appUserCase.Data.IsHospital != *userCase.IsHospital {
|
||||
userCaseData["is_hospital"] = appUserCase.Data.IsHospital
|
||||
}
|
||||
} else {
|
||||
userCaseData["is_hospital"] = appUserCase.Data.IsHospital
|
||||
}
|
||||
}
|
||||
|
||||
// 慢性疾病
|
||||
if appUserCase.Data.OtherDisease != "" {
|
||||
if userCase.ChronicDisease != "" {
|
||||
if appUserCase.Data.OtherDisease != userCase.ChronicDisease {
|
||||
userCaseData["chronic_disease"] = appUserCase.Data.OtherDisease
|
||||
}
|
||||
} else {
|
||||
userCaseData["chronic_disease"] = appUserCase.Data.OtherDisease
|
||||
}
|
||||
}
|
||||
|
||||
// 目前肝脏状态
|
||||
if appUserCase.Data.LiverStatus != "" {
|
||||
if userCase.LiverStatus != "" {
|
||||
if appUserCase.Data.LiverStatus != userCase.LiverStatus {
|
||||
userCaseData["liver_status"] = appUserCase.Data.LiverStatus
|
||||
}
|
||||
} else {
|
||||
userCaseData["liver_status"] = appUserCase.Data.LiverStatus
|
||||
}
|
||||
}
|
||||
|
||||
// 修改用户病例数据
|
||||
if len(userCaseData) > 0 {
|
||||
err := userCaseDao.EditUserCaseById(tx, userCase.UserCaseId, userCaseData)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if len(appUserCase.Data.DiseasesList) > 0 {
|
||||
userCaseDiseaseItemDao := dao.UserCaseDiseaseItemDao{}
|
||||
|
||||
// 删除所患疾病列表
|
||||
maps := make(map[string]interface{})
|
||||
maps["user_case_id"] = userCase.UserCaseId
|
||||
err := userCaseDiseaseItemDao.DeleteUserCaseDiseaseItem(tx, maps)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 所患疾病列表
|
||||
if len(appUserCase.Data.DiseasesList) > 0 {
|
||||
for _, data := range appUserCase.Data.DiseasesList {
|
||||
userCaseDiseaseItemDao := dao.UserCaseDiseaseItemDao{}
|
||||
baseDiseaseClassDao := dao.BaseDiseaseClassDao{}
|
||||
|
||||
// 获取基础数据-疾病分类
|
||||
baseDiseaseClass, err := baseDiseaseClassDao.GetBaseDiseaseClassByAppIden(data.UUID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 新增所患疾病列表
|
||||
userCaseDiseaseItem := &model.UserCaseDiseaseItem{
|
||||
UserCaseId: userCase.UserCaseId,
|
||||
DiseaseClassId: baseDiseaseClass.DiseaseClassId,
|
||||
AppIden: data.UUID,
|
||||
Duration: data.Year,
|
||||
Genotype: data.Info,
|
||||
}
|
||||
|
||||
userCaseDiseaseItem, err = userCaseDiseaseItemDao.AddUserCaseDiseaseItem(tx, userCaseDiseaseItem)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user