From abba0476290f49b320d034d438f669ee8a3b0ad5 Mon Sep 17 00:00:00 2001 From: iamhujiebin <458249864@qq.com> Date: Tue, 20 Jun 2023 23:26:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:medals=E6=98=AF=E5=BF=85=E9=A1=BB=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cv/user_cv/user.go | 2 ++ cv/user_cv/utils.go | 7 +++++++ domain/service/user_s/user.go | 1 + route/user_r/user.go | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/cv/user_cv/user.go b/cv/user_cv/user.go index 1d535ee..9a51145 100644 --- a/cv/user_cv/user.go +++ b/cv/user_cv/user.go @@ -100,6 +100,7 @@ type CvUserBase struct { //VIP用户过期时间(只有自己查询自己,才返回) VipExpireTime *int64 `json:"vipExpireTime"` Svip rpc.CvSvip `json:"svip"` // svip结构,等级+权限 + Medals []uint32 `json:"medals"` // 勋章列表 MedalInfo []medal_cv.CvMedal `json:"medalInfo"` // 勋章列表 Headwear *headwear_cv.CvHeadwear `json:"headwear"` // 当前使用的头饰 Ride property_cv.CvProperty `json:"ride"` // 当前使用的座驾 @@ -191,6 +192,7 @@ func GetUserBases(userIds []mysql.ID, myUserId mysql.ID) ([]*CvUserBase, error) IsPrettyCode: user.IsPrettyCode(), IsVip: vips[user.ID] != nil, IsOfficialStaff: superManagerMap[user.ID], + Medals: IfLogoutMedals(IfLogout(user.LogoutTime), []uint32{}, medals[user.ID]), MedalInfo: IfLogoutMedalInfo(invisible, []medal_cv.CvMedal{}, medalInfo[user.ID]), Ride: IfLogoutRide(IfLogout(user.LogoutTime), property_cv.CvProperty{}, property_cv.CvProperty{ Id: rides[user.ID], diff --git a/cv/user_cv/utils.go b/cv/user_cv/utils.go index 827e24e..c8a6291 100644 --- a/cv/user_cv/utils.go +++ b/cv/user_cv/utils.go @@ -78,6 +78,13 @@ func IfLogout(logoutTime int64) bool { return logoutTime > 0 && time.Now().Unix() > logoutTime } +func IfLogoutMedals(condition bool, trueVal, falseVal []uint32) []uint32 { + if condition { + return trueVal + } + return falseVal +} + func IfLogoutMedalInfo(condition bool, trueVal, falseVal []medal_cv.CvMedal) []medal_cv.CvMedal { if condition { return trueVal diff --git a/domain/service/user_s/user.go b/domain/service/user_s/user.go index f76cd74..7a768ba 100644 --- a/domain/service/user_s/user.go +++ b/domain/service/user_s/user.go @@ -285,6 +285,7 @@ func userToDetailOne(model *domain.Model, user *user_m.User, myUserId mysql.ID, IsOfficialStaff: isOfficialStaff, VipExpireTime: vipExpireTime, Svip: svip, + Medals: IfLogoutMedals(IfLogout(user.LogoutTime), []uint32{}, medals), MedalInfo: IfLogoutMedalInfo(IfLogout(user.LogoutTime), []medal_cv.CvMedal{}, medalInfo), Headwear: IfLogoutHeadwear(IfLogout(user.LogoutTime), nil, headwear), Ride: IfLogoutRide(IfLogout(user.LogoutTime), property_cv.CvProperty{}, ride), diff --git a/route/user_r/user.go b/route/user_r/user.go index a21243d..87cf5cf 100644 --- a/route/user_r/user.go +++ b/route/user_r/user.go @@ -89,7 +89,7 @@ func UserDetailByExternalId(c *gin.Context) (*mycontext.MyContext, error) { if n == 0 { // FIXME:转异步执行 err = tim_m.FlushHiloInfo(*cvUserDetail.ExternalId, cvUserDetail.IsVip, cvUserDetail.IsPrettyCode, - nil, cvUserDetail.MyGroupPowerName, cvUserDetail.Noble.Level) + cvUserDetail.Medals, cvUserDetail.MyGroupPowerName, cvUserDetail.Noble.Level) if err == nil { redisCli.GetRedis().Set(model, user_k.GetKeySyncTimHilo(userId), "1", time.Minute) } else { -- 2.22.0