diff --git a/_const/enum/cp_e/level.go b/_const/enum/cp_e/level.go index 014ffe047d77fea81f8585d16e4c904c0d7ffc9e..8d49d2df9402f1a09cd46c530de32d02981543a3 100644 --- a/_const/enum/cp_e/level.go +++ b/_const/enum/cp_e/level.go @@ -38,6 +38,14 @@ var ( CpLevel4: "icon4.png", CpLevel5: "icon5.png", } + // cp等级称号 + CpLevelTitle = map[CpLevel]uint{ + CpLevel1: 252, + CpLevel2: 253, + CpLevel3: 254, + CpLevel4: 255, + CpLevel5: 256, + } // cp特权名称 CpPrivilegeNameMsgId = map[CpPrivilege]uint{ CpPrivilegeSpace: 234, diff --git a/cv/cp_cv/space.go b/cv/cp_cv/space.go index 83d3fd7bcc15bc458cc4a392ed8626b0825b88e6..c792cd7eb39591d88342cab2bbb8a818ec510524 100644 --- a/cv/cp_cv/space.go +++ b/cv/cp_cv/space.go @@ -29,6 +29,7 @@ type CvCpLevel struct { ExpireAtUnix int64 `json:"expireAtUnix,omitempty"` // 有效期,时间戳 SettlementDate string `json:"settlementDate"` // 等级过期时间 MaxLevel cp_e.CpLevel `json:"maxLevel"` // cp最大的等级 + Title string `json:"title,omitempty"` // 称号翻译 } // 资源等级 diff --git a/route/middleHandle.go b/route/middleHandle.go index 7f4ec559fbae7f5754a02eb1c0aac940a7edcb74..14425535d53e42b8761d6e1592b664aa7c1056b2 100755 --- a/route/middleHandle.go +++ b/route/middleHandle.go @@ -102,6 +102,12 @@ func LoggerHandle(c *gin.Context) { c.Set(mycontext.APP_VERSION, appVersion) c.Set(mycontext.URL, reqUri) c.Set(mycontext.METHOD, method) + lang := header.Get(mycontext.LANGUAGE) + c.Set(mycontext.LANGUAGE, lang) + carrier := header.Get(mycontext.CARRIER) + c.Set(mycontext.CARRIER, carrier) + timezone := header.Get(mycontext.TIMEZONE) + c.Set(mycontext.TIMEZONE, timezone) userId, _ := req.GetUserId(c) diff --git a/route/user_r/inner.go b/route/user_r/inner.go index 1fe9ea38ed171371f55072ae11b453d0b9973a3a..d251c21a13df1e5fd6a014424ba0b9bdd23ce97c 100644 --- a/route/user_r/inner.go +++ b/route/user_r/inner.go @@ -95,12 +95,14 @@ func GetUserBagId(c *gin.Context) (*mycontext.MyContext, error) { } type GetUserCpReq struct { - Id mysql.ID `form:"id" binding:"required"` + Id mysql.ID `form:"id" binding:"required"` + Language string `form:"language"` } // @Tags 用户-内部 // @Summary 获取用户cp // @Param id query int true "用户id" +// @Param language query string true "语言" // @Success 200 {object} cp_cv.CvCp // @Router /inner/user/cp [get] func GetUserCp(c *gin.Context) (*mycontext.MyContext, error) { @@ -151,10 +153,16 @@ func GetUserCp(c *gin.Context) (*mycontext.MyContext, error) { return myContext, err } // 返回值 + title := "" + if msgId, ok := cp_e.CpLevelTitle[level.Level]; ok { + title = cp_cv.GetTranslate(msgId, req.Language) + } response = cp_cv.CvCp{ CpUserInfo: userBases[cpUserId], CpLevel: cp_cv.CvCpLevel{ - Level: cpLevel, + Level: cpLevel, + Points: cp_e.CpLevelPoints[cpLevel] + level.Points, + Title: title, }, MyPrivilegeList: myPrivilegeList, CpDays: int(time.Now().Sub(cpRelation.CreatedTime).Hours()/24) + 1,