From 2b3539ad5643b324693117b597e19a691d23842d Mon Sep 17 00:00:00 2001 From: hujiebin Date: Thu, 3 Aug 2023 16:04:00 +0800 Subject: [PATCH] Feature/user svip vip level --- route/router.go | 3 ++- route/user_r/inner.go | 58 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 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..1d66443 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,62 @@ 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, + Birthday: &user.Birthday, + 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