From 05324289e34ef19c6854f664659bbba83e17b346 Mon Sep 17 00:00:00 2001 From: hujiebin Date: Fri, 9 Jun 2023 19:35:08 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=8C=87=E5=AE=9Acp=E5=AF=B9?= 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 5e0043c..bed7df4 100644 --- a/rpc/user.go +++ b/rpc/user.go @@ -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) // 随机一个 -- 2.22.0