Commit c4357bf8 authored by chenweijian's avatar chenweijian

家族

parent 0a820e67
......@@ -650,14 +650,16 @@ type GroupPowerInfo struct {
type GroupPower struct {
Id uint64 `json:"id"`
Name mysql.Str `json:"name"`
Nameplate mysql.Str `json:"nameplate"` // 铭牌
Declaration mysql.Str `json:"declaration"` // 宣言
Icon mysql.Str `json:"icon"` // 头像
Grade mysql.Num `json:"grade" gorm:"-"` // 等级
Exp mysql.Num `json:"exp" gorm:"-"` // 当前经验值
NextExp mysql.Num `json:"nextExp" gorm:"-"` // 升到下一级需要的经验值
GradeName mysql.Str `json:"gradeName"` // 等级称号
GradeMedal mysql.Str `json:"gradeMedal"` // 等级勋章图片
Nameplate mysql.Str `json:"nameplate"` // 铭牌
Declaration mysql.Str `json:"declaration"` // 宣言
Icon mysql.Str `json:"icon"` // 头像
Grade mysql.Num `json:"grade" gorm:"-"` // 等级
Exp mysql.Num `json:"exp" gorm:"-"` // 当前经验值
NextExp mysql.Num `json:"nextExp" gorm:"-"` // 升到下一级需要的经验值
GradeName mysql.Str `json:"gradeName"` // 等级称号
GradeMedal mysql.Str `json:"gradeMedal"` // 等级勋章图片
MemberNum mysql.Num `json:"memberNum" gorm:"-"` // 当前人数
MemberMax mysql.Num `json:"memberMax" gorm:"-"` // 最大人数
}
type GroupPowerUser struct {
......
......@@ -49,20 +49,20 @@ func (this *GroupPower) Get(model *domain.Model) (*GroupPower, error) {
return group, nil
}
func (gpu *GroupPowerUser) GetBy(model *domain.Model, pageSize, pageIndex int) ([]*GroupPowerUser, int, bool, error) {
func (gpu *GroupPowerUser) GetBy(model *domain.Model, pageSize, pageIndex int) ([]*GroupPowerUser, int64, int, bool, error) {
rows := make([]*GroupPowerUser, 0)
db := model.Db.Model(GroupPowerUser{}).Where(gpu).Order("field(`role`, 2, 3, 1)")
var count int64
err := db.Count(&count).Error
if err != nil {
return nil, 0, false, err
return nil, 0, 0, false, err
}
err = db.Limit(pageSize).Offset(pageIndex - 1).Find(&rows).Error
if err != nil {
return nil, 0, false, err
return nil, 0, 0, false, err
}
nextPageIndex, hasNextPage := common.PageNext(count, pageIndex, pageSize)
return rows, nextPageIndex, hasNextPage, nil
return rows, count, nextPageIndex, hasNextPage, nil
}
func (gpu *GroupPowerUser) GetGroupPowerUser(model *domain.Model) (*GroupPowerUser, error) {
......
......@@ -717,7 +717,7 @@ func GroupPowerInfo(c *gin.Context) (*mycontext.MyContext, error) {
return myContext, myerr.WrapErr(err)
}
gpU := &groupPower_m.GroupPowerUser{GroupPowerId: gpInfo.ID}
members, _, _, err := gpU.GetBy(model, 5, 0)
members, total, _, _, err := gpU.GetBy(model, 5, 0)
if err != nil {
return myContext, myerr.WrapErr(err)
}
......@@ -738,6 +738,7 @@ func GroupPowerInfo(c *gin.Context) (*mycontext.MyContext, error) {
info := &group_power_cv.GroupPower{
Id: gpInfo.ID, Name: gpInfo.Name, Nameplate: gpInfo.Nameplate, Declaration: gpInfo.Declaration, Icon: gpInfo.Icon,
Grade: gpInfo.Grade, Exp: gpInfo.Exp, NextExp: gpInfo.NextExp, GradeName: gpInfo.GradeName, GradeMedal: gpInfo.GradeMedal,
MemberNum: mysql.Num(total), MemberMax: 300,
}
res := group_power_cv.GroupPowerInfo{Info: info, Members: resMembers}
......@@ -824,7 +825,7 @@ func GroupPowerMembers(c *gin.Context) (*mycontext.MyContext, error) {
}
}
members, nextPageIndex, hasNextPage, err := gpU.GetBy(model, pageSize, pageIndex)
members, _, nextPageIndex, hasNextPage, err := gpU.GetBy(model, pageSize, pageIndex)
if err != nil {
return myContext, err
}
......
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