Commit 52253598 authored by hujiebin's avatar hujiebin

Merge branch 'feature/cp-new' into feature/3.9.0

parents 2d562c8f db47bb04
...@@ -38,6 +38,14 @@ var ( ...@@ -38,6 +38,14 @@ var (
CpLevel4: "icon4.png", CpLevel4: "icon4.png",
CpLevel5: "icon5.png", CpLevel5: "icon5.png",
} }
// cp等级称号
CpLevelTitle = map[CpLevel]uint{
CpLevel1: 252,
CpLevel2: 253,
CpLevel3: 254,
CpLevel4: 255,
CpLevel5: 256,
}
// cp特权名称 // cp特权名称
CpPrivilegeNameMsgId = map[CpPrivilege]uint{ CpPrivilegeNameMsgId = map[CpPrivilege]uint{
CpPrivilegeSpace: 234, CpPrivilegeSpace: 234,
......
...@@ -29,6 +29,7 @@ type CvCpLevel struct { ...@@ -29,6 +29,7 @@ type CvCpLevel struct {
ExpireAtUnix int64 `json:"expireAtUnix,omitempty"` // 有效期,时间戳 ExpireAtUnix int64 `json:"expireAtUnix,omitempty"` // 有效期,时间戳
SettlementDate string `json:"settlementDate"` // 等级过期时间 SettlementDate string `json:"settlementDate"` // 等级过期时间
MaxLevel cp_e.CpLevel `json:"maxLevel"` // cp最大的等级 MaxLevel cp_e.CpLevel `json:"maxLevel"` // cp最大的等级
Title string `json:"title,omitempty"` // 称号翻译
} }
// 资源等级 // 资源等级
......
...@@ -102,6 +102,12 @@ func LoggerHandle(c *gin.Context) { ...@@ -102,6 +102,12 @@ func LoggerHandle(c *gin.Context) {
c.Set(mycontext.APP_VERSION, appVersion) c.Set(mycontext.APP_VERSION, appVersion)
c.Set(mycontext.URL, reqUri) c.Set(mycontext.URL, reqUri)
c.Set(mycontext.METHOD, method) 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) userId, _ := req.GetUserId(c)
......
...@@ -96,11 +96,13 @@ func GetUserBagId(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -96,11 +96,13 @@ func GetUserBagId(c *gin.Context) (*mycontext.MyContext, error) {
type GetUserCpReq struct { type GetUserCpReq struct {
Id mysql.ID `form:"id" binding:"required"` Id mysql.ID `form:"id" binding:"required"`
Language string `form:"language"`
} }
// @Tags 用户-内部 // @Tags 用户-内部
// @Summary 获取用户cp // @Summary 获取用户cp
// @Param id query int true "用户id" // @Param id query int true "用户id"
// @Param language query string true "语言"
// @Success 200 {object} cp_cv.CvCp // @Success 200 {object} cp_cv.CvCp
// @Router /inner/user/cp [get] // @Router /inner/user/cp [get]
func GetUserCp(c *gin.Context) (*mycontext.MyContext, error) { func GetUserCp(c *gin.Context) (*mycontext.MyContext, error) {
...@@ -151,10 +153,16 @@ func GetUserCp(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -151,10 +153,16 @@ func GetUserCp(c *gin.Context) (*mycontext.MyContext, error) {
return myContext, err return myContext, err
} }
// 返回值 // 返回值
title := ""
if msgId, ok := cp_e.CpLevelTitle[level.Level]; ok {
title = cp_cv.GetTranslate(msgId, req.Language)
}
response = cp_cv.CvCp{ response = cp_cv.CvCp{
CpUserInfo: userBases[cpUserId], CpUserInfo: userBases[cpUserId],
CpLevel: cp_cv.CvCpLevel{ CpLevel: cp_cv.CvCpLevel{
Level: cpLevel, Level: cpLevel,
Points: cp_e.CpLevelPoints[cpLevel] + level.Points,
Title: title,
}, },
MyPrivilegeList: myPrivilegeList, MyPrivilegeList: myPrivilegeList,
CpDays: int(time.Now().Sub(cpRelation.CreatedTime).Hours()/24) + 1, CpDays: int(time.Now().Sub(cpRelation.CreatedTime).Hours()/24) + 1,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment