diff --git a/rpc/user.go b/rpc/user.go index 8a5f18ec061f0e1a5c459cae4d48b5c81dee365a..5e0043c7216b6e80468294134805f3c0418f6b1c 100644 --- a/rpc/user.go +++ b/rpc/user.go @@ -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) // 随机一个