From 09d285736cf010eead4b271a9cf4c590a7fbc13b Mon Sep 17 00:00:00 2001 From: hujiebin Date: Tue, 14 Mar 2023 15:29:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E4=B8=8A=E5=AE=B6=E6=97=8F=E4=B9=8B?= =?UTF-8?q?=E6=98=9F=E4=B8=89=E4=B8=AA=E6=A6=9C=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cv/group_power_cv/groupPower.go | 10 +++++----- domain/model/groupPower_m/group_star.go | 21 +++++++++++++++++++++ route/group_power_r/group_power.go | 24 +++++++++++++++++++++++- 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/cv/group_power_cv/groupPower.go b/cv/group_power_cv/groupPower.go index 137c2bf..79e3d59 100644 --- a/cv/group_power_cv/groupPower.go +++ b/cv/group_power_cv/groupPower.go @@ -651,9 +651,9 @@ func GetAllPowerDiamond(period string) (map[string]string, error) { } type GroupPowerInfo struct { - Info *GroupPower `json:"info"` - Members []*GroupPowerUser `json:"members"` - Stars []*GroupPowerStart `json:"stars"` + Info *GroupPower `json:"info"` + Members []*GroupPowerUser `json:"members"` + Stars []*GroupPowerStar `json:"stars,omitempty"` } type GroupPower struct { @@ -676,8 +676,8 @@ type GroupPowerUser struct { Role groupPower_e.GroupPowerUserRole `json:"role"` } -type GroupPowerStart struct { - User *user_m.UserTiny `json:"user"` +type GroupPowerStar struct { + User user_cv.CvUserTiny `json:"user"` RankingType groupPower_e.GroupPowerRankType `json:"rankingType"` } diff --git a/domain/model/groupPower_m/group_star.go b/domain/model/groupPower_m/group_star.go index c58c8fd..c8e235b 100644 --- a/domain/model/groupPower_m/group_star.go +++ b/domain/model/groupPower_m/group_star.go @@ -66,3 +66,24 @@ func GetGroupPowerMonthStarRank(model *domain.Model, groupPowerId mysql.ID, _typ } return res, nil } + +// 获取家族之星三个排行榜的各自第一名 +func GetGroupPowerMonthStartTop1(model *domain.Model, groupPowerId mysql.ID) ([]*GroupPowerMonthStar, error) { + var res []*GroupPowerMonthStar + r1, err := GetGroupPowerMonthStarRank(model, groupPowerId, groupPower_e.GroupPowerStarTypeFamous, 0, 1) + if err != nil { + return res, err + } + r2, err := GetGroupPowerMonthStarRank(model, groupPowerId, groupPower_e.GroupPowerStarTypeActive, 0, 1) + if err != nil { + return res, err + } + r3, err := GetGroupPowerMonthStarRank(model, groupPowerId, groupPower_e.GroupPowerStarTypeCharm, 0, 1) + if err != nil { + return res, err + } + res = append(res, r1...) + res = append(res, r2...) + res = append(res, r3...) + return res, nil +} diff --git a/route/group_power_r/group_power.go b/route/group_power_r/group_power.go index a6ad2db..ef67867 100644 --- a/route/group_power_r/group_power.go +++ b/route/group_power_r/group_power.go @@ -748,7 +748,29 @@ func GroupPowerInfo(c *gin.Context) (*mycontext.MyContext, error) { Grade: gpInfo.Grade, Exp: gpInfo.Exp, NextExp: gpInfo.NextExp, GradeName: gpInfo.GradeName, GradeMedal: gpInfo.GradeMedal, MemberNum: mysql.Num(total), MemberMax: mysql.Num(group_power_cv.GroupPowerGradePrivilegeNum[groupPowerGrade[gp.ID].Grade][0].Num), } - res := group_power_cv.GroupPowerInfo{Info: info, Members: resMembers} + // 补上家族之星三个榜一 + stars, err := groupPower_m.GetGroupPowerMonthStartTop1(model, gp.ID) + if err != nil { + return myContext, myerr.WrapErr(err) + } + var cvStar []*group_power_cv.GroupPowerStar + if len(stars) > 0 { + var userIds []uint64 + for _, star := range stars { + userIds = append(userIds, star.UserId) + } + userM, err := user_cv.GetUserTinyMap(userIds) + if err != nil { + return myContext, err + } + for _, star := range stars { + cvStar = append(cvStar, &group_power_cv.GroupPowerStar{ + User: userM[star.UserId], + RankingType: groupPower_e.GroupPowerRankType(star.Type), + }) + } + } + res := group_power_cv.GroupPowerInfo{Info: info, Members: resMembers, Stars: cvStar} resp.ResponseOk(c, res) return myContext, nil -- 2.22.0