diff --git a/cv/cp_cv/cp.go b/cv/cp_cv/cp.go index c0a2a309fbb81cb50a2ef33fc9d882767a501f05..e7bec329f074b7bd2dfbd7055974714c07c76fd3 100644 --- a/cv/cp_cv/cp.go +++ b/cv/cp_cv/cp.go @@ -1,6 +1,9 @@ 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"` +} diff --git a/route/router.go b/route/router.go index 60311fe5506972ff5e484547318f5e308ad7586a..b88d04b7ba37f333d1f3968bde1c8406c404f4ad 100755 --- a/route/router.go +++ b/route/router.go @@ -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") diff --git a/route/user_r/inner.go b/route/user_r/inner.go index d08d5d45cdec228e93075beb381a87b7cecb45b0..b591a48077cc612186c2d001f6bf9acb5f3b15af 100644 --- a/route/user_r/inner.go +++ b/route/user_r/inner.go @@ -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 +}