Commit 64b173dd authored by hujiebin's avatar hujiebin

feat:memberMax

parent 2bf5d01b
......@@ -70,10 +70,12 @@ type CvUserDetail struct {
}
type GroupPower struct {
Id uint64 `json:"id"` // 群主所在的势力ID
Name string `json:"name"` // 群主所在的势力的名称
Nameplate string `json:"nameplate"` // 势力铭牌
Grade groupPower_e.GroupPowerGrade `json:"grade"` // 等级
Id uint64 `json:"id"` // 群主所在的势力ID
Name string `json:"name"` // 群主所在的势力的名称
Nameplate string `json:"nameplate"` // 势力铭牌
Grade groupPower_e.GroupPowerGrade `json:"grade"` // 等级
MemberNum uint32 `json:"memberNum,omitempty"` // 当前成员数
MemberMax uint32 `json:"memberMax,omitempty"` // 成员上限
}
type CvUserTiny struct {
......@@ -321,13 +323,41 @@ func getUserDetails(model *domain.Model, users []*user_m.User, myUserId mysql.ID
if err != nil {
return nil, err
}
groupPowerUsers, err := groupPower_m.MGetGroupPowerUsers(model, gpIds)
if err != nil {
return nil, err
}
// 成员上限
groupPowerNames := make(map[mysql.ID]string, 0)
groupPowerInfos := make(map[mysql.ID]groupPower_m.GroupPowerInfo)
groupPowerGrades := make(map[mysql.ID]groupPower_m.GroupPowerGrade)
groupPowerMembers := make(map[mysql.ID][2]int) // 0->memberNum 1->memberLimit
for uid, gid := range groupPowers {
groupPowerNames[uid] = powerNames[gid]
groupPowerInfos[uid] = groupPowerInfoMap[gid]
groupPowerGrades[uid] = groupPowerGradeMap[gid]
var memberMax int
grade := groupPowerGradeMap[gid].Grade
if grade >= groupPower_e.GroupPowerGrade0 && grade <= groupPower_e.GroupPowerGradeMax {
if grade == groupPower_e.GroupPowerGrade0 {
memberMax = 300
}
if grade == groupPower_e.GroupPowerGrade1 {
memberMax = 500
}
if grade == groupPower_e.GroupPowerGrade2 {
memberMax = 800
}
if grade == groupPower_e.GroupPowerGrade3 {
memberMax = 1200
}
}
memberNum := len(groupPowerUsers[gid])
if memberNum > memberMax {
memberMax = memberNum
}
groupPowerMembers[uid] = [2]int{memberNum, memberMax}
}
up := user_m.UserProperty{}
......@@ -372,7 +402,7 @@ func getUserDetails(model *domain.Model, users []*user_m.User, myUserId mysql.ID
cvUserDetail, err := userToDetail(users[i], myUserId, userTradeUnion, likeMap, likeMeMap, rels,
vips[users[i].ID] != nil, vips[users[i].ID], svips[users[i].ID], headwear, ride,
wealthGradeMap, charmGradeMap, activeGradeMap, medals, medalInfo, rooms, groupPowers, groupPowerNames, groupPowerInfos, groupPowerGrades, nobles, superManagerMap)
wealthGradeMap, charmGradeMap, activeGradeMap, medals, medalInfo, rooms, groupPowers, groupPowerNames, groupPowerInfos, groupPowerGrades, groupPowerMembers, nobles, superManagerMap)
if err != nil {
return nil, err
}
......@@ -392,7 +422,7 @@ func userToDetail(user *user_m.User, myUserId mysql.ID, userTradeUnion *user_m.U
likeMeMap map[mysql.ID]bool, hvMap map[mysql.ID]Relation, isVip bool, vipExpireTime *int64, svip rpc.CvSvip, headwear *headwear_cv.CvHeadwear, ride property_cv.CvProperty,
wealthGradeMap map[mysql.ID]uint32, charmGradeMap map[mysql.ID]uint32, actityGradeMap map[mysql.ID]uint32,
medals map[uint64][]uint32, medalInfo map[uint64][]medal_cv.CvMedal, rooms map[mysql.ID]string,
powers map[mysql.ID]uint64, powerNames map[mysql.ID]string, groupPowerInfos map[mysql.ID]groupPower_m.GroupPowerInfo, powerGrades map[mysql.ID]groupPower_m.GroupPowerGrade, nobles map[mysql.ID]noble_m.UserNoble, superManagerMap map[uint64]bool) (*CvUserDetail, error) {
powers map[mysql.ID]uint64, powerNames map[mysql.ID]string, groupPowerInfos map[mysql.ID]groupPower_m.GroupPowerInfo, powerGrades map[mysql.ID]groupPower_m.GroupPowerGrade, groupPowerMembers map[mysql.ID][2]int, nobles map[mysql.ID]noble_m.UserNoble, superManagerMap map[uint64]bool) (*CvUserDetail, error) {
cvUserDetail := &CvUserDetail{
CvUserBase: CvUserBase{
Id: &user.ID,
......@@ -537,6 +567,8 @@ func userToDetail(user *user_m.User, myUserId mysql.ID, userTradeUnion *user_m.U
Name: groupPowerInfos[user.ID].Name,
Nameplate: groupPowerInfos[user.ID].Nameplate,
Grade: powerGrades[user.ID].Grade,
MemberNum: mysql.Num(groupPowerMembers[user.ID][0]),
MemberMax: mysql.Num(groupPowerMembers[user.ID][1]),
}
if n, ok := nobles[user.ID]; ok && n.Level > 0 {
cvUserDetail.Noble = noble_cv.CvNoble{
......
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