Commit 31d69133 authored by hujiebin's avatar hujiebin

获取用户cp关系

parent 3fbf4730
......@@ -241,6 +241,39 @@ func SendUserRide(model *domain.Model, userId mysql.ID, rideId mysql.ID, day mys
return nil
}
// cp关系
type CvCpRelation struct {
CpId uint64 `json:"cpId"`
UserId uint64 `json:"userId"`
CpUserId uint64 `json:"cpUserId"`
}
// 获取用户cp关系
func GetUserCpRelation(model *domain.Model, userId mysql.ID) (*CvCpRelation, error) {
type Response struct {
Code int `json:"code"`
Message string `json:"message"`
Data *CvCpRelation `json:"data"`
}
_url := fmt.Sprintf("%v://%v/inner/user/cpRelation", defaultUserServerScheme, getUserHost())
resp, err := HttpGet(model, _url, nil, map[string][]string{
"id": {fmt.Sprintf("%d", userId)},
})
if err != nil {
model.Log.Errorf("GetUserCpRelation fail:%v", err)
return nil, err
}
response := new(Response)
if err = json.Unmarshal(resp, response); err != nil {
model.Log.Errorf("GetUserCpRelation json fail:%v", err)
return nil, err
}
if response.Data != nil && response.Data.CpUserId > 0 {
return response.Data, nil
}
return nil, 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