Commit 05324289 authored by hujiebin's avatar hujiebin

获取指定cp对

parent 31d69133
......@@ -274,6 +274,39 @@ func GetUserCpRelation(model *domain.Model, userId mysql.ID) (*CvCpRelation, err
return nil, nil
}
// 获取指定cp对
func MGetUserCpPairs(model *domain.Model, userIds []mysql.ID) ([][2]mysql.ID, error) {
type Response struct {
Code int `json:"code"`
Message string `json:"message"`
Data [][2]mysql.ID `json:"data"`
}
var res [][2]mysql.ID
if len(userIds) <= 0 {
return res, nil
}
var userIdsStr []string
for _, userId := range userIds {
userIdsStr = append(userIdsStr, fmt.Sprintf("%d", userId))
}
_url := fmt.Sprintf("%v://%v/inner/user/cp/pair", defaultUserServerScheme, getUserHost())
resp, err := HttpGet(model, _url, nil, map[string][]string{
"ids": userIdsStr,
})
if err != nil {
model.Log.Errorf("MGetUserLevel fail:%v", err)
return res, err
}
response := new(Response)
if err = json.Unmarshal(resp, response); err != nil {
model.Log.Errorf("MGetUserLevel json fail:%v", err)
return res, err
} else {
res = response.Data
}
return res, nil
}
func getUserHost() string {
l := len(UserServerHost)
r := rand.Intn(l) // 随机一个
......
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