Commit fbb2d85e authored by chenweijian's avatar chenweijian

座驾cp头像

parent e6a49662
......@@ -151,11 +151,15 @@ func GetUserBases(userIds []mysql.ID, myUserId mysql.ID) ([]*CvUserBase, error)
//rp := res_m.ResProperty{}
//properties, err := rp.GetAll(mysql.Db)
_, myArea, err := user_m.GetUserCountryArea(domain.CreateModelNil(), myUserId)
if err != nil {
return nil, err
propertiesArea := make(map[int]map[uint64]property_cv.CvProperty)
for _, v := range []int{1, 2} {
properties, err := GetPropertyAll(mysql.Db, v)
if err != nil {
return nil, err
}
propertiesArea[v] = properties
}
properties, err := GetPropertyAll(mysql.Db, myArea)
areaMap, err := user_m.GetUserAreaMap(domain.CreateModelNil(), userIds)
if err != nil {
return nil, err
}
......@@ -173,6 +177,7 @@ func GetUserBases(userIds []mysql.ID, myUserId mysql.ID) ([]*CvUserBase, error)
cvUserBases := []*CvUserBase{}
for i := 0; i < len(users); i++ {
user := users[i]
properties := propertiesArea[areaMap[user.ID]]
invisible := IfLogout(user.LogoutTime)
invisibleAvatar := ""
invisibleNick := user.Code
......
......@@ -157,3 +157,21 @@ func GetUserCountryArea(model *domain.Model, userId mysql.ID) (string, int, erro
}
return res.Name, res.Area, nil
}
//获取用户的国家所属的区域(是否阿语区)
func GetUserAreaMap(model *domain.Model, userIds []mysql.ID) (map[mysql.ID]int, error) {
type info struct {
Id mysql.ID
Area int
}
rows := make([]*info, 0)
sql := "select user.id, rc.area from user left join res_country rc on user.country = rc.name where user.id in (?);"
if err := model.DB().Raw(sql, userIds).Scan(&rows).Error; err != nil {
return nil, myerr.WrapErr(err)
}
res := make(map[mysql.ID]int)
for _, v := range rows {
res[v.Id] = v.Area
}
return res, nil
}
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