Commit f657fcb8 authored by chenweijian's avatar chenweijian

Merge branch 'fix/show_property_image' into 'master'

座驾cp头像

See merge request !15
parents e6a49662 fbb2d85e
...@@ -151,11 +151,15 @@ func GetUserBases(userIds []mysql.ID, myUserId mysql.ID) ([]*CvUserBase, error) ...@@ -151,11 +151,15 @@ 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)
_, myArea, err := user_m.GetUserCountryArea(domain.CreateModelNil(), myUserId) propertiesArea := make(map[int]map[uint64]property_cv.CvProperty)
if err != nil { for _, v := range []int{1, 2} {
return nil, err 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 { if err != nil {
return nil, err return nil, err
} }
...@@ -173,6 +177,7 @@ func GetUserBases(userIds []mysql.ID, myUserId mysql.ID) ([]*CvUserBase, error) ...@@ -173,6 +177,7 @@ func GetUserBases(userIds []mysql.ID, myUserId mysql.ID) ([]*CvUserBase, error)
cvUserBases := []*CvUserBase{} cvUserBases := []*CvUserBase{}
for i := 0; i < len(users); i++ { for i := 0; i < len(users); i++ {
user := users[i] user := users[i]
properties := propertiesArea[areaMap[user.ID]]
invisible := IfLogout(user.LogoutTime) invisible := IfLogout(user.LogoutTime)
invisibleAvatar := "" invisibleAvatar := ""
invisibleNick := user.Code invisibleNick := user.Code
......
...@@ -157,3 +157,21 @@ func GetUserCountryArea(model *domain.Model, userId mysql.ID) (string, int, erro ...@@ -157,3 +157,21 @@ func GetUserCountryArea(model *domain.Model, userId mysql.ID) (string, int, erro
} }
return res.Name, res.Area, nil 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