From 31d691332929a7cc4d3f54eda548dc3374d42137 Mon Sep 17 00:00:00 2001 From: hujiebin Date: Fri, 9 Jun 2023 17:41:17 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=94=A8=E6=88=B7cp=E5=85=B3?= =?UTF-8?q?=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rpc/user.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/rpc/user.go b/rpc/user.go index 8a5f18e..5e0043c 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) // 随机一个 -- 2.22.0