Commit ae256c50 authored by chenweijian's avatar chenweijian

cp座驾

parent f19b2537
...@@ -95,7 +95,7 @@ func GetPropertyById(resPropertyId mysql.ID) (CvProperty, error) { ...@@ -95,7 +95,7 @@ func GetPropertyById(resPropertyId mysql.ID) (CvProperty, error) {
}, nil }, 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{} rp := res_m.ResProperty{}
properties, err := rp.GetAll(mysql.Db) properties, err := rp.GetAll(mysql.Db)
if err != nil { if err != nil {
...@@ -103,7 +103,7 @@ func GetPropertyAll(db *gorm.DB) (map[uint64]CvProperty, error) { ...@@ -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{} userIds := []uint64{}
for _, value := range propertieAvatarMap { for _, value := range propertieAvatarMap {
......
...@@ -151,7 +151,11 @@ func GetUserBases(userIds []mysql.ID, myUserId mysql.ID) ([]*CvUserBase, error) ...@@ -151,7 +151,11 @@ func GetUserBases(userIds []mysql.ID, myUserId mysql.ID) ([]*CvUserBase, error)
//rp := res_m.ResProperty{} //rp := res_m.ResProperty{}
//properties, err := rp.GetAll(mysql.Db) //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 { if err != nil {
return nil, err return nil, err
} }
...@@ -338,7 +342,7 @@ func getMedalInfoMap(db *gorm.DB, medals map[uint64][]uint32) (map[uint64][]uint ...@@ -338,7 +342,7 @@ func getMedalInfoMap(db *gorm.DB, medals map[uint64][]uint32) (map[uint64][]uint
return medalIds, medalMap, nil 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{} rp := res_m.ResProperty{}
properties, err := rp.GetAll(mysql.Db) properties, err := rp.GetAll(mysql.Db)
if err != nil { if err != nil {
...@@ -346,7 +350,7 @@ func GetPropertyAll(db *gorm.DB) (map[uint64]property_cv.CvProperty, error) { ...@@ -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 var userIds []uint64
for _, value := range propertyAvatarMap { for _, value := range propertyAvatarMap {
......
...@@ -33,6 +33,7 @@ type ResPropertyAvatar struct { ...@@ -33,6 +33,7 @@ type ResPropertyAvatar struct {
Type res_e.ResPropertyAvatarType Type res_e.ResPropertyAvatarType
SendUserId mysql.ID SendUserId mysql.ID
ReceiverUserId mysql.ID ReceiverUserId mysql.ID
Area int
} }
func InitResPropertyDiamond(model *domain.Model, resPropertyId mysql.ID, diamondNum mysql.Num, second mysql.Num) *ResPropertyDiamond { func InitResPropertyDiamond(model *domain.Model, resPropertyId mysql.ID, diamondNum mysql.Num, second mysql.Num) *ResPropertyDiamond {
......
...@@ -144,3 +144,16 @@ func GetUsers(model *domain.Model, ids []mysql.ID) ([]*User, error) { ...@@ -144,3 +144,16 @@ func GetUsers(model *domain.Model, ids []mysql.ID) ([]*User, error) {
} }
return res, nil 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
}
...@@ -172,7 +172,11 @@ func (s *UserService) GetUserDetail(userId mysql.ID, myUserId mysql.ID, lang str ...@@ -172,7 +172,11 @@ func (s *UserService) GetUserDetail(userId mysql.ID, myUserId mysql.ID, lang str
//rp := res_m.ResProperty{} //rp := res_m.ResProperty{}
//properties, err := rp.GetAll(mysql.Db) //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 { if err != nil {
return nil, err return nil, err
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment