diff --git a/cv/property_cv/property.go b/cv/property_cv/property.go index c6af321e51d139ad7bd0e74fe4b0073c87f0557e..6492d05888197f933bd442a9fbcb979822263c7c 100644 --- a/cv/property_cv/property.go +++ b/cv/property_cv/property.go @@ -95,7 +95,7 @@ func GetPropertyById(resPropertyId mysql.ID) (CvProperty, error) { }, nil } -func GetPropertyAll(db *gorm.DB) (map[uint64]CvProperty, error) { +func GetPropertyAll(db *gorm.DB, area int) (map[uint64]CvProperty, error) { rp := res_m.ResProperty{} properties, err := rp.GetAll(mysql.Db) if err != nil { @@ -103,7 +103,7 @@ func GetPropertyAll(db *gorm.DB) (map[uint64]CvProperty, error) { } //获取座驾头像 - propertieAvatarMap, err := (&res_m.ResPropertyAvatar{}).GetAll(mysql.Db) + propertieAvatarMap, err := (&res_m.ResPropertyAvatar{Area: area}).GetAll(mysql.Db) userIds := []uint64{} for _, value := range propertieAvatarMap { diff --git a/cv/user_cv/user.go b/cv/user_cv/user.go index 9a5114509dd12aa91d990dee2aec130d5e61daa7..8ac46fd8d8af759ec6e29af92cd814c0721ba760 100644 --- a/cv/user_cv/user.go +++ b/cv/user_cv/user.go @@ -151,7 +151,11 @@ func GetUserBases(userIds []mysql.ID, myUserId mysql.ID) ([]*CvUserBase, error) //rp := res_m.ResProperty{} //properties, err := rp.GetAll(mysql.Db) - properties, err := GetPropertyAll(mysql.Db) + _, myArea, err := user_m.GetUserCountryArea(domain.CreateModelNil(), myUserId) + if err != nil { + return nil, err + } + properties, err := GetPropertyAll(mysql.Db, myArea) if err != nil { return nil, err } @@ -338,7 +342,7 @@ func getMedalInfoMap(db *gorm.DB, medals map[uint64][]uint32) (map[uint64][]uint return medalIds, medalMap, nil } -func GetPropertyAll(db *gorm.DB) (map[uint64]property_cv.CvProperty, error) { +func GetPropertyAll(db *gorm.DB, area int) (map[uint64]property_cv.CvProperty, error) { rp := res_m.ResProperty{} properties, err := rp.GetAll(mysql.Db) if err != nil { @@ -346,7 +350,7 @@ func GetPropertyAll(db *gorm.DB) (map[uint64]property_cv.CvProperty, error) { } //获取座驾头像 - propertyAvatarMap, err := (&res_m.ResPropertyAvatar{}).GetAll(mysql.Db) + propertyAvatarMap, err := (&res_m.ResPropertyAvatar{Area: area}).GetAll(mysql.Db) var userIds []uint64 for _, value := range propertyAvatarMap { diff --git a/domain/model/res_m/property.go b/domain/model/res_m/property.go index d390314f510d638d73bbf1acf61960171a82a14a..0d5cbcc6bd118b1fb0ac2499de25916354416e9a 100644 --- a/domain/model/res_m/property.go +++ b/domain/model/res_m/property.go @@ -33,6 +33,7 @@ type ResPropertyAvatar struct { Type res_e.ResPropertyAvatarType SendUserId mysql.ID ReceiverUserId mysql.ID + Area int } func InitResPropertyDiamond(model *domain.Model, resPropertyId mysql.ID, diamondNum mysql.Num, second mysql.Num) *ResPropertyDiamond { diff --git a/domain/model/user_m/user.go b/domain/model/user_m/user.go index d1b9f36ec6462baa0fc2fd44546a8ad687351248..15ee7d8d4428e36e28f1425d3784897da24204da 100755 --- a/domain/model/user_m/user.go +++ b/domain/model/user_m/user.go @@ -144,3 +144,16 @@ func GetUsers(model *domain.Model, ids []mysql.ID) ([]*User, error) { } return res, nil } + +//获取用户的国家,和所属的区域(是否阿语区) +func GetUserCountryArea(model *domain.Model, userId mysql.ID) (string, int, error) { + type info struct { + Name string + Area int + } + res := new(info) + if err := model.Db.WithContext(model.Context).Raw("select name, area from res_country where name = (select country from user where id = ?)", userId).First(&res).Error; err != nil { + return "", 0, myerr.WrapErr(err) + } + return res.Name, res.Area, nil +} diff --git a/domain/service/user_s/user.go b/domain/service/user_s/user.go index be27029127b18c778ea42f8cc35d1ada6d2e7ea2..71cc8c4e22f5a2f060f23df0d70f931a63105193 100644 --- a/domain/service/user_s/user.go +++ b/domain/service/user_s/user.go @@ -172,7 +172,11 @@ func (s *UserService) GetUserDetail(userId mysql.ID, myUserId mysql.ID, lang str //rp := res_m.ResProperty{} //properties, err := rp.GetAll(mysql.Db) - properties, err := property_cv.GetPropertyAll(mysql.Db) + _, myArea, err := user_m.GetUserCountryArea(model, myUserId) + if err != nil { + return nil, err + } + properties, err := property_cv.GetPropertyAll(mysql.Db, myArea) if err != nil { return nil, err }