diff --git a/cv/group_cv/group.go b/cv/group_cv/group.go index 73029a6636ae765dac19f612efb97f5b2673fb68..3dbb01e5cdb303f3ebaf675a29aaca309563ac5a 100644 --- a/cv/group_cv/group.go +++ b/cv/group_cv/group.go @@ -4,6 +4,7 @@ import ( "git.hilo.cn/hilo-common/domain" "git.hilo.cn/hilo-common/utils" "hilo-group/_const/enum/game_e" + "hilo-group/_const/enum/groupPower_e" "hilo-group/_const/enum/group_e" "hilo-group/_const/enum/online_e" "hilo-group/cv/billboard_cv" @@ -60,15 +61,23 @@ type MemberListInfo struct { // AppMemberDefinedData": [ // 群成员自定义字段 【暂时不用】 } +type GroupPower struct { + Id uint64 `json:"groupPowerId"` // 群主所在的势力ID + Name string `json:"groupPowerName"` // 群主所在的势力的名称 + Nameplate string `json:"groupPowerNameplate"` // 势力铭牌 + Grade groupPower_e.GroupPowerGrade `json:"grade"` // 等级 +} + type GroupInfo struct { GroupBasicInfo // hilo业务 - EntryLevel uint32 `json:"entryLevel"` // obsolete - HasOnMic bool `json:"hasOnMic"` // 房间麦上是否有人 - GroupPowerId uint64 `json:"groupPowerId"` // 群主所在的势力ID - GroupPowerName string `json:"groupPowerName"` // 群主所在的势力的名称 - GroupPowerNameplate string `json:"groupPowerNameplate"` // 势力铭牌 + EntryLevel uint32 `json:"entryLevel"` // obsolete + HasOnMic bool `json:"hasOnMic"` // 房间麦上是否有人 + GroupPowerId uint64 `json:"groupPowerId"` // 群主所在的势力ID + GroupPowerName string `json:"groupPowerName"` // 群主所在的势力的名称 + GroupPowerNameplate string `json:"groupPowerNameplate"` // 势力铭牌 + GroupPower GroupPower `json:"groupPower"` // 势力信息 // "AppDefinedData": 群组维度的自定义字段 【暂时不用】 MemberList []MemberListInfo @@ -313,7 +322,7 @@ func BuildJoinedGroupInfo(myService *domain.Service, myUserId uint64, groupIds [ for _, i := range groupIds { owners = append(owners, groupInfo[i].Owner) } - powerIds, powerNames, powerNameplates, err := group_power_cv.BatchGetGroupPower(model.Db, owners) + powerIds, powerNames, powerNameplates, powerGrades, err := group_power_cv.BatchGetGroupPower(model.Db, owners) if err != nil { return nil, 0, err } @@ -393,6 +402,12 @@ func BuildJoinedGroupInfo(myService *domain.Service, myUserId uint64, groupIds [ GroupPowerId: powerIds[g.Owner], GroupPowerName: powerNames[g.Owner], GroupPowerNameplate: powerNameplates[g.Owner], + GroupPower: GroupPower{ + Id: powerIds[g.Owner], + Name: powerNames[g.Owner], + Nameplate: powerNameplates[g.Owner], + Grade: powerGrades[g.Owner], + }, }, MicUsers: micUsers, RoomUserCount: uint(roomCount[i]), diff --git a/cv/group_power_cv/groupPower.go b/cv/group_power_cv/groupPower.go index 6a2752416ced5a617ac5926386058a5305d958c1..137c2bf10f607af4844692fc955eb3d2edd29428 100644 --- a/cv/group_power_cv/groupPower.go +++ b/cv/group_power_cv/groupPower.go @@ -234,13 +234,13 @@ func GetCvGroupPowerUsers(groupPowerId uint64) ([]mysql.ID, error) { } // return userId->powerId userId->powerName userId->powerNameplate -func BatchGetGroupPower(db *gorm.DB, userIds []uint64) (map[uint64]uint64, map[uint64]string, map[uint64]string, error) { +func BatchGetGroupPower(db *gorm.DB, userIds []uint64) (map[uint64]uint64, map[uint64]string, map[uint64]string, map[uint64]groupPower_e.GroupPowerGrade, error) { if len(userIds) <= 0 { - return nil, nil, nil, nil + return nil, nil, nil, nil, nil } groupPowers, err := groupPower_m.GetGroupPowerMap(db, userIds) if err != nil { - return nil, nil, nil, err + return nil, nil, nil, nil, err } gpIds := make([]uint64, 0) @@ -249,15 +249,21 @@ func BatchGetGroupPower(db *gorm.DB, userIds []uint64) (map[uint64]uint64, map[u } powerNames, powerNameplates, err := groupPower_m.GetGroupPowerNames(db, gpIds) if err != nil { - return nil, nil, nil, err + return nil, nil, nil, nil, err + } + groupPowerGrade, err := groupPower_m.MGetGroupPowerGrade(domain.CreateModelNil(), gpIds) + if err != nil { + return nil, nil, nil, nil, err } groupPowerNames := make(map[mysql.ID]string, 0) groupPowerNameplates := make(map[mysql.ID]string, 0) + groupPowerGrades := make(map[mysql.ID]groupPower_e.GroupPowerGrade, 0) for i, g := range groupPowers { groupPowerNames[i] = powerNames[g] groupPowerNameplates[i] = powerNameplates[g] + groupPowerGrades[i] = groupPowerGrade[g].Grade } - return groupPowers, groupPowerNames, groupPowerNameplates, nil + return groupPowers, groupPowerNames, groupPowerNameplates, groupPowerGrades, nil } //获取国家势力的所有用户数量 diff --git a/route/group_power_r/group_power.go b/route/group_power_r/group_power.go index fe94dd8b6938e9a0c4950730f20f5979e31fa07a..0044001305f570de9cae7cb0956ead1a0072772f 100644 --- a/route/group_power_r/group_power.go +++ b/route/group_power_r/group_power.go @@ -377,7 +377,7 @@ func GetGroupPowerGroups(c *gin.Context) (*mycontext.MyContext, error) { groupIds = append(groupIds, i.ImGroupId) owners = append(owners, i.Owner) } - powerIds, powerNames, powerNameplates, err := group_power_cv.BatchGetGroupPower(model.Db, owners) + powerIds, powerNames, powerNameplates, powerGrades, err := group_power_cv.BatchGetGroupPower(model.Db, owners) if err != nil { return myContext, err } @@ -493,6 +493,12 @@ func GetGroupPowerGroups(c *gin.Context) (*mycontext.MyContext, error) { GroupPowerId: powerIds[i.Owner], GroupPowerName: powerNames[i.Owner], GroupPowerNameplate: powerNameplates[i.Owner], + GroupPower: group_cv.GroupPower{ + Id: powerIds[i.Owner], + Name: powerNames[i.Owner], + Nameplate: powerNameplates[i.Owner], + Grade: powerGrades[i.Owner], + }, }, MicUsers: micUsers, RoomUserCount: uint(roomCount[i.ImGroupId]), diff --git a/route/group_r/group_info.go b/route/group_r/group_info.go index 091219508e696551fc0ca3b93109a25470587cc6..160ed4d898ccd01ba2f692c7c6551e713c57bd80 100644 --- a/route/group_r/group_info.go +++ b/route/group_r/group_info.go @@ -133,7 +133,7 @@ func GetTheirGroups(c *gin.Context) (*mycontext.MyContext, error) { } model.Log.Info("GetTheirGroups: theirRoles - ", theirRoles) - powerIds, powerNames, powerNameplates, err := group_power_cv.BatchGetGroupPower(model.Db, owners) + powerIds, powerNames, powerNameplates, powerGrades, err := group_power_cv.BatchGetGroupPower(model.Db, owners) if err != nil { return myContext, err } @@ -276,6 +276,12 @@ func GetTheirGroups(c *gin.Context) (*mycontext.MyContext, error) { GroupPowerId: powerIds[gi.Owner], GroupPowerName: powerNames[gi.Owner], GroupPowerNameplate: powerNameplates[gi.Owner], + GroupPower: group_cv.GroupPower{ + Id: powerIds[gi.Owner], + Name: powerNames[gi.Owner], + Nameplate: powerNameplates[gi.Owner], + Grade: powerGrades[gi.Owner], + }, }, MicUsers: micUsers, RoomUserCount: uint(roomCount[i.GroupId]), diff --git a/route/group_r/group_list.go b/route/group_r/group_list.go index 8745e81f030661a18aa560b92360fc1e33e069ef..5a31d97031ea7bbfb83a2a119dd36bb03771245b 100644 --- a/route/group_r/group_list.go +++ b/route/group_r/group_list.go @@ -246,7 +246,7 @@ func GetPopularGroups(c *gin.Context) (*mycontext.MyContext, error) { groupIds = append(groupIds, i.ImGroupId) owners = append(owners, i.Owner) } - powerIds, powerNames, powerNameplates, err := group_power_cv.BatchGetGroupPower(model.Db, owners) + powerIds, powerNames, powerNameplates, powerGrades, err := group_power_cv.BatchGetGroupPower(model.Db, owners) if err != nil { return myContext, err } @@ -342,6 +342,12 @@ func GetPopularGroups(c *gin.Context) (*mycontext.MyContext, error) { GroupPowerId: powerIds[i.Owner], GroupPowerName: powerNames[i.Owner], GroupPowerNameplate: powerNameplates[i.Owner], + GroupPower: group_cv.GroupPower{ + Id: powerIds[i.Owner], + Name: powerNames[i.Owner], + Nameplate: powerNameplates[i.Owner], + Grade: powerGrades[i.Owner], + }, }, MicUsers: micUsers, RoomUserCount: uint(roomCount[i.ImGroupId]), @@ -469,7 +475,7 @@ func GetLatestGroups(c *gin.Context) (*mycontext.MyContext, error) { for _, group := range groupInfos { owners = append(owners, group.Owner) } - powerIds, powerNames, powerNameplates, err := group_power_cv.BatchGetGroupPower(model.Db, owners) + powerIds, powerNames, powerNameplates, powerGrades, err := group_power_cv.BatchGetGroupPower(model.Db, owners) if err != nil { return myContext, err } @@ -560,6 +566,12 @@ func GetLatestGroups(c *gin.Context) (*mycontext.MyContext, error) { GroupPowerId: powerIds[group.Owner], GroupPowerName: powerNames[group.Owner], GroupPowerNameplate: powerNameplates[group.Owner], + GroupPower: group_cv.GroupPower{ + Id: powerIds[group.Owner], + Name: powerNames[group.Owner], + Nameplate: powerNameplates[group.Owner], + Grade: powerGrades[group.Owner], + }, }, MicUsers: micUsers, RoomUserCount: uint(roomCount[group.ImGroupId]), @@ -1291,7 +1303,7 @@ func GetGroupByCountry(c *gin.Context) (*mycontext.MyContext, error) { groupIds = append(groupIds, i.ImGroupId) owners = append(owners, i.Owner) } - powerIds, powerNames, powerNameplates, err := group_power_cv.BatchGetGroupPower(model.Db, owners) + powerIds, powerNames, powerNameplates, powerGrades, err := group_power_cv.BatchGetGroupPower(model.Db, owners) if err != nil { return myContext, err } @@ -1375,6 +1387,12 @@ func GetGroupByCountry(c *gin.Context) (*mycontext.MyContext, error) { GroupPowerId: powerIds[i.Owner], GroupPowerName: powerNames[i.Owner], GroupPowerNameplate: powerNameplates[i.Owner], + GroupPower: group_cv.GroupPower{ + Id: powerIds[i.Owner], + Name: powerNames[i.Owner], + Nameplate: powerNameplates[i.Owner], + Grade: powerGrades[i.Owner], + }, }, MicUsers: []user_cv.CvUserTiny{}, RoomUserCount: uint(roomCount[i.ImGroupId]),