Commit f2f086fe authored by hujiebin's avatar hujiebin

Merge branch 'feature/cp-entry-effect' into 'master'

feature/cp-entry-effect

See merge request !9
parents ed06aa7a c33ba259
package cp_cv
import "hilo-user/cv/user_cv"
import (
"hilo-user/_const/enum/cp_e"
"hilo-user/cv/user_cv"
)
// cp信息
type CvCp struct {
......@@ -18,3 +21,10 @@ type CvCpRelation struct {
CpUserId uint64 `json:"cpUserId"`
CpUserAvatar string `json:"cpUserAvatar,omitempty"`
}
// cp进场特效信息
type CvCpEntryEffect struct {
CpLevel cp_e.CpLevel `json:"cpLevel"`
CpUserAvatar string `json:"cpUserAvatar"`
CpEntryEffect bool `json:"cpEntryEffect"`
}
......@@ -61,6 +61,7 @@ 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进场特效信息,高频接口,需要额外处理
}
// 道具相关
innerProp := inner.Group("/prop")
......
......@@ -8,6 +8,7 @@ import (
"hilo-user/_const/enum/cp_e"
"hilo-user/cv/cp_cv"
"hilo-user/cv/user_cv"
"hilo-user/domain/cache/user_c"
"hilo-user/domain/model/bag_m"
"hilo-user/domain/model/cp_m"
"hilo-user/domain/model/noble_m"
......@@ -260,3 +261,58 @@ func GetUserCpPair(c *gin.Context) (*mycontext.MyContext, error) {
resp.ResponseOk(c, response)
return myContext, nil
}
// @Tags 用户-内部
// @Summary 获取用户cpEffect
// @Param id query int true "用户id"
// @Param language query string true "语言"
// @Success 200 {object} cp_cv.CvCpEntryEffect
// @Router /inner/user/cp/entryEffect [get]
func GetUserCpEntryEffect(c *gin.Context) (*mycontext.MyContext, error) {
myContext := mycontext.CreateMyContext(c.Keys)
var model = domain.CreateModelContext(myContext)
var req GetUserCpReq
if err := c.ShouldBindQuery(&req); err != nil {
return myContext, err
}
userId := req.Id
var response cp_cv.CvCpEntryEffect
cpLevel := cp_e.CpLevel0
cpRelation, exists := cp_m.GetCpRelation(model, userId)
if !exists {
resp.ResponseOk(c, response)
return myContext, nil
}
level := cp_m.GetCpLevel(model, cpRelation.Id)
if level.ExpireAt.Before(time.Now()) {
level.ExpireAt = time.Now().AddDate(0, 1, 0)
}
cpLevel = level.Level
cpUserId := cpRelation.UserId2
if cpUserId == userId {
cpUserId = cpRelation.UserId1
}
response.CpLevel = cpLevel
userPrivileges, err := cp_m.MGetUserSvipPrivilege(model, []uint64{userId})
if err != nil {
return myContext, err
}
privilegeList := cp_cv.CopyCpLevelPrivilegeList(level.Level, "en")
for i, v := range privilegeList {
if v.CanSwitch {
privilegeList[i].UserSwitch = userPrivileges[userId][v.Type]
}
}
// 我的特权,有开关并且打开才返回
for _, v := range privilegeList {
if v.Type == cp_e.CpPrivilegeRoomEffect && v.UserSwitch {
response.CpEntryEffect = true
}
}
if cpUser, _ := user_c.GetUserTinyById(model, cpUserId); cpUser != nil {
response.CpUserAvatar = cpUser.Avatar
}
resp.ResponseOk(c, response)
return myContext, nil
}
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