修改地址数据int为string
This commit is contained in:
parent
04b6469827
commit
c3d4333220
@ -125,11 +125,11 @@ func (r *Login) Login(c *gin.Context) {
|
||||
IsFamilyHistory: nil,
|
||||
IsPregnant: nil,
|
||||
ExpectedDate: nil,
|
||||
ProvinceId: nil,
|
||||
ProvinceId: "",
|
||||
Province: "",
|
||||
CityId: nil,
|
||||
CityId: "",
|
||||
City: "",
|
||||
CountyId: nil,
|
||||
CountyId: "",
|
||||
County: "",
|
||||
}
|
||||
userInfoDao := dao.UserInfoDao{}
|
||||
|
||||
@ -16,11 +16,11 @@ type UserInfoDto struct {
|
||||
IsFamilyHistory *int `json:"is_family_history"` // 是否存在家族病史(0:未知 1:是 2:否)
|
||||
IsPregnant *int `json:"is_pregnant"` // 是否怀孕(1:无计划 2:计划中 3:已怀孕 4:家有宝宝)
|
||||
ExpectedDate *string `json:"expected_date"` // 预产期
|
||||
ProvinceId *int64 `json:"province_id"` // 省份id
|
||||
ProvinceId string `json:"province_id"` // 省份id
|
||||
Province string `json:"province"` // 省份
|
||||
CityId *int64 `json:"city_id"` // 城市id
|
||||
CityId string `json:"city_id"` // 城市id
|
||||
City string `json:"city"` // 城市
|
||||
CountyId *int64 `json:"county_id"` // 区县id
|
||||
CountyId string `json:"county_id"` // 区县id
|
||||
County string `json:"county"` // 区县
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
|
||||
@ -16,11 +16,11 @@ type UserInfo struct {
|
||||
IsFamilyHistory *int `gorm:"column:is_family_history;type:tinyint(1);comment:是否存在家族病史(0:未知 1:是 2:否)" json:"is_family_history"`
|
||||
IsPregnant *int `gorm:"column:is_pregnant;type:tinyint(1);comment:是否怀孕(1:无计划 2:计划中 3:已怀孕 4:家有宝宝)" json:"is_pregnant"`
|
||||
ExpectedDate *LocalTime `gorm:"column:expected_date;type:datetime;comment:预产期" json:"expected_date"`
|
||||
ProvinceId *int64 `gorm:"column:province_id;type:int(11);comment:省份id" json:"province_id"`
|
||||
ProvinceId string `gorm:"column:province_id;type:int(11);comment:省份id" json:"province_id"`
|
||||
Province string `gorm:"column:province;type:varchar(40);comment:省份" json:"province"`
|
||||
CityId *int64 `gorm:"column:city_id;type:int(11);comment:城市id" json:"city_id"`
|
||||
CityId string `gorm:"column:city_id;type:int(11);comment:城市id" json:"city_id"`
|
||||
City string `gorm:"column:city;type:varchar(50);comment:城市" json:"city"`
|
||||
CountyId *int64 `gorm:"column:county_id;type:int(11);comment:区县id" json:"county_id"`
|
||||
CountyId string `gorm:"column:county_id;type:int(11);comment:区县id" json:"county_id"`
|
||||
County string `gorm:"column:county;type:varchar(255);comment:区县" json:"county"`
|
||||
Model
|
||||
}
|
||||
|
||||
@ -251,20 +251,21 @@ func (r *UserService) GetAppUserInfo(tx *gorm.DB, user *model.User, userInfo *mo
|
||||
if appUserInfo.Data.ProvinceID != nil {
|
||||
// 获取省份数据
|
||||
baseAreaDao := dao.BaseAreaDao{}
|
||||
if userInfo.ProvinceId != nil {
|
||||
if *appUserInfo.Data.ProvinceID != *userInfo.ProvinceId {
|
||||
userInfoData["province_id"] = appUserInfo.Data.ProvinceID
|
||||
if userInfo.ProvinceId != "" {
|
||||
provinceId := fmt.Sprintf("%d", *appUserInfo.Data.ProvinceID)
|
||||
if provinceId != userInfo.ProvinceId {
|
||||
userInfoData["province_id"] = *appUserInfo.Data.ProvinceID
|
||||
|
||||
baseArea, err := baseAreaDao.GetBaseAreaById(int64(*appUserInfo.Data.ProvinceID))
|
||||
baseArea, err := baseAreaDao.GetBaseAreaById(*appUserInfo.Data.ProvinceID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
userInfoData["province"] = baseArea.Name
|
||||
}
|
||||
} else {
|
||||
userInfoData["province_id"] = appUserInfo.Data.ProvinceID
|
||||
userInfoData["province_id"] = *appUserInfo.Data.ProvinceID
|
||||
|
||||
baseArea, err := baseAreaDao.GetBaseAreaById(int64(*appUserInfo.Data.ProvinceID))
|
||||
baseArea, err := baseAreaDao.GetBaseAreaById(*appUserInfo.Data.ProvinceID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -276,20 +277,21 @@ func (r *UserService) GetAppUserInfo(tx *gorm.DB, user *model.User, userInfo *mo
|
||||
if appUserInfo.Data.CityID != nil {
|
||||
// 获取城市数据
|
||||
baseAreaDao := dao.BaseAreaDao{}
|
||||
if userInfo.CityId != nil {
|
||||
if *appUserInfo.Data.CityID != *userInfo.CityId {
|
||||
userInfoData["city_id"] = appUserInfo.Data.CityID
|
||||
if userInfo.CityId != "" {
|
||||
cityId := fmt.Sprintf("%d", *appUserInfo.Data.CityID)
|
||||
if cityId != userInfo.CityId {
|
||||
userInfoData["city_id"] = *appUserInfo.Data.CityID
|
||||
|
||||
baseArea, err := baseAreaDao.GetBaseAreaById(int64(*appUserInfo.Data.CityID))
|
||||
baseArea, err := baseAreaDao.GetBaseAreaById(*appUserInfo.Data.CityID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
userInfoData["city"] = baseArea.Name
|
||||
}
|
||||
} else {
|
||||
userInfoData["city_id"] = appUserInfo.Data.CityID
|
||||
userInfoData["city_id"] = *appUserInfo.Data.CityID
|
||||
|
||||
baseArea, err := baseAreaDao.GetBaseAreaById(int64(*appUserInfo.Data.CityID))
|
||||
baseArea, err := baseAreaDao.GetBaseAreaById(*appUserInfo.Data.CityID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -301,20 +303,21 @@ func (r *UserService) GetAppUserInfo(tx *gorm.DB, user *model.User, userInfo *mo
|
||||
if appUserInfo.Data.CountyID != nil {
|
||||
// 获取区县数据
|
||||
baseAreaDao := dao.BaseAreaDao{}
|
||||
if userInfo.CountyId != nil {
|
||||
if *appUserInfo.Data.CountyID != *userInfo.CountyId {
|
||||
userInfoData["county_id"] = appUserInfo.Data.CountyID
|
||||
if userInfo.CountyId != "" {
|
||||
countyId := fmt.Sprintf("%d", *appUserInfo.Data.CountyID)
|
||||
if countyId != userInfo.CountyId {
|
||||
userInfoData["county_id"] = *appUserInfo.Data.CountyID
|
||||
|
||||
baseArea, err := baseAreaDao.GetBaseAreaById(int64(*appUserInfo.Data.CountyID))
|
||||
baseArea, err := baseAreaDao.GetBaseAreaById(*appUserInfo.Data.CountyID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
userInfoData["county"] = baseArea.Name
|
||||
}
|
||||
} else {
|
||||
userInfoData["county_id"] = appUserInfo.Data.CountyID
|
||||
userInfoData["county_id"] = *appUserInfo.Data.CountyID
|
||||
|
||||
baseArea, err := baseAreaDao.GetBaseAreaById(int64(*appUserInfo.Data.CountyID))
|
||||
baseArea, err := baseAreaDao.GetBaseAreaById(*appUserInfo.Data.CountyID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -836,8 +839,8 @@ func (r *UserService) PutUser(userId int64, req requests.PutUser) (bool, error)
|
||||
return false, errors.New("省份错误")
|
||||
}
|
||||
|
||||
if userInfo.ProvinceId != nil {
|
||||
if provinceId != *userInfo.ProvinceId {
|
||||
if userInfo.ProvinceId != "" {
|
||||
if req.ProvinceId != userInfo.ProvinceId {
|
||||
userInfoData["province_id"] = provinceId
|
||||
userInfoData["province"] = baseArea.Name
|
||||
}
|
||||
@ -859,8 +862,8 @@ func (r *UserService) PutUser(userId int64, req requests.PutUser) (bool, error)
|
||||
return false, errors.New("城市错误")
|
||||
}
|
||||
|
||||
if userInfo.CityId != nil {
|
||||
if cityId != *userInfo.CityId {
|
||||
if userInfo.CityId != "" {
|
||||
if req.CityId != userInfo.CityId {
|
||||
userInfoData["city_id"] = cityId
|
||||
|
||||
userInfoData["city"] = baseArea.Name
|
||||
@ -882,8 +885,8 @@ func (r *UserService) PutUser(userId int64, req requests.PutUser) (bool, error)
|
||||
return false, errors.New("城市错误")
|
||||
}
|
||||
|
||||
if userInfo.CountyId != nil {
|
||||
if countyId != *userInfo.CountyId {
|
||||
if userInfo.CountyId != "" {
|
||||
if req.CountyId != userInfo.CountyId {
|
||||
userInfoData["county_id"] = countyId
|
||||
|
||||
userInfoData["county"] = baseArea.Name
|
||||
@ -949,7 +952,7 @@ func (r *UserService) CheckUserInfo(userInfo *model.UserInfo) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
if userInfo.ProvinceId == nil {
|
||||
if userInfo.ProvinceId == "" {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user