From b0859340d9c9c09f9eeb126536e26d86d1fe55f3 Mon Sep 17 00:00:00 2001 From: hujiebin Date: Thu, 3 Aug 2023 15:37:51 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=94=A8=E6=88=B7svip/noble/?= =?UTF-8?q?level=E7=AD=89=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- route/router.go | 3 ++- route/user_r/inner.go | 57 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/route/router.go b/route/router.go index 11d8437..ef4619c 100644 --- a/route/router.go +++ b/route/router.go @@ -76,7 +76,8 @@ func InitRouter() *gin.Engine { innerUser.GET("/cp", wrapper(user_r.GetUserCp)) innerUser.GET("/cpRelations", wrapper(user_r.MGetUserCpRelation)) innerUser.GET("/cp/pair", wrapper(user_r.GetUserCpPair)) - innerUser.GET("/cp/entryEffect", wrapper(user_r.GetUserCpEntryEffect)) // 获取cp进场特效信息,高频接口,需要额外处理 + innerUser.GET("/cp/entryEffect", wrapper(user_r.GetUserCpEntryEffect)) // 获取cp进场特效信息,高频接口,需要额外处理 + innerUser.GET("/svipNobleLevel", wrapper(user_r.MGetUserSvipNobleLevel)) // 获取用户svip/noble/level等信息 } // 道具相关 innerProp := inner.Group("/prop") diff --git a/route/user_r/inner.go b/route/user_r/inner.go index b2422f9..9cd45f9 100644 --- a/route/user_r/inner.go +++ b/route/user_r/inner.go @@ -4,9 +4,11 @@ import ( "git.hilo.cn/hilo-common/domain" "git.hilo.cn/hilo-common/mycontext" "git.hilo.cn/hilo-common/resource/mysql" + "git.hilo.cn/hilo-common/rpc" "github.com/gin-gonic/gin" "hilo-user/_const/enum/cp_e" "hilo-user/cv/cp_cv" + "hilo-user/cv/noble_cv" "hilo-user/cv/user_cv" "hilo-user/domain/cache/user_c" "hilo-user/domain/model/bag_m" @@ -56,6 +58,61 @@ func MGetUserLevels(c *gin.Context) (*mycontext.MyContext, error) { return myCtx, nil } +type MGetUserSvipVipLevelReq struct { + Ids []mysql.ID `form:"ids" binding:"required"` +} + +// @Tags 用户-内部 +// @Summary 批量获取用户等级 +// @Param ids query string true "用户id,如:ids=1&ids=2&ids=3" +// @Success 200 {object} user_cv.CvUserDetail +// @Router /inner/user/svipNobleLevel [get] +func MGetUserSvipNobleLevel(c *gin.Context) (*mycontext.MyContext, error) { + myCtx := mycontext.CreateMyContext(c.Keys) + var model = domain.CreateModelContext(myCtx) + var req MGetUserLevelReq + if err := c.ShouldBindQuery(&req); err != nil { + return myCtx, err + } + wealthGrade, err := user_m.MGetWealthGrade(model, req.Ids) + if err != nil { + return myCtx, err + } + charmGrade, err := user_m.MGetCharmGrade(model, req.Ids) + activeGrade, err := user_m.MGetActiveGrade(model, req.Ids) + nobleLevel, err := noble_m.BatchGetNobleLevel(model, req.Ids) + svip, err := rpc.MGetUserSvip(model, req.Ids) + users, err := user_m.GetUserMapByIds(model, req.Ids) + response := make(map[uint64]user_cv.CvUserDetail) + for _, userId := range req.Ids { + user := users[userId] + response[userId] = user_cv.CvUserDetail{ + CvUserBase: user_cv.CvUserBase{ + Id: &user.ID, + Avatar: &user.Avatar, + ExternalId: &user.ExternalId, + Nick: &user.Nick, + Sex: &user.Sex, + Country: &user.Country, + CountryIcon: &user.CountryIcon, + Code: &user.Code, + Svip: rpc.CvSvip{ + SvipLevel: svip[userId].SvipLevel, + }, + Noble: noble_cv.CvNoble{ + Level: nobleLevel[userId], + }, + }, + WealthUserGrade: wealthGrade[userId], + CharmUserGrade: charmGrade[userId], + ActivityUserGrade: activeGrade[userId], + } + } + + resp.ResponseOk(c, response) + return myCtx, nil +} + type GetUserBagReq struct { BagId mysql.ID `form:"bagId" binding:"required"` } -- 2.22.0