This commit is contained in:
lwl0608 2024-09-04 19:05:49 +08:00
parent eedc49b4b2
commit afa4ef12db
5 changed files with 41 additions and 2 deletions

View File

@ -272,6 +272,7 @@ type GetZoneMemberListV2Data struct {
List []*ZoneMemberVo `json:"list"`
Offset int64 `json:"offset"`
More int32 `json:"more"`
Total int64 `json:"total"`
}
type GetZoneMemberListV2Resp struct {

View File

@ -142,7 +142,7 @@ func ZoneMemberListV2(ctx *gin.Context) {
ReplyErrCodeMsg(ctx, errcode.ErrCodeBadParam)
return
}
list, ec, err := service.DefaultService.ZoneMemberListV2(ctx, req)
list, total, ec, err := service.DefaultService.ZoneMemberListV2(ctx, req)
if ec != errcode.ErrCodeVasSrvOk {
logger.Error("ZoneMemberList fail, req: %v, ec: %v", util.ToJson(req), ec)
if ec == errcode.ErrCodeVasSrvFail && err != nil {
@ -155,6 +155,7 @@ func ZoneMemberListV2(ctx *gin.Context) {
data := &vasproto.GetZoneMemberListV2Data{
List: list,
Offset: req.Offset + int64(len(list)),
Total: total,
}
if int64(len(list)) >= req.Limit {
data.More = 1

View File

@ -465,6 +465,31 @@ func (m *Mysql) GetZoneMemberListV2(ctx *gin.Context, tx *sqlx.Tx, zid, offset,
return
}
// 获取空间成员列表
func (m *Mysql) GetZoneMemberCnt(ctx *gin.Context, tx *sqlx.Tx, zid int64, memType int32) (cnt int64, err error) {
type CntSt struct {
Cnt int64 `json:"cnt"`
}
cntSt := CntSt{}
sqlStr := fmt.Sprintf(fmt.Sprintf("select count(1) as cnt from %s where zid=? and member_type=?", TableVasZoneMember))
args := []interface{}{zid, memType}
if tx != nil {
err = tx.GetContext(ctx, &cntSt, sqlStr, args...)
} else {
db := m.getDBVas()
err = db.SelectContext(ctx, &cntSt, sqlStr, args...)
}
if err == sql.ErrNoRows {
err = nil
return
}
if err != nil {
return
}
cnt = cntSt.Cnt
return
}
// 获取空间成员列表
func (m *Mysql) SearchZoneMember(ctx *gin.Context, tx *sqlx.Tx, zid, memMid int64) (list []*dbstruct.ZoneMember, err error) {
list = make([]*dbstruct.ZoneMember, 0)

View File

@ -1006,6 +1006,15 @@ func (v *Vas) GetZoneMemberListV2(ctx *gin.Context, zid, offset, limit int64, me
return
}
// 空间成员列表
func (v *Vas) GetZoneMemberCnt(ctx *gin.Context, zid int64, memType int32) (cnt int64, err error) {
cnt, err = v.store.GetZoneMemberCnt(ctx, nil, zid, memType)
if err != nil {
return
}
return
}
// 搜索空间成员
func (v *Vas) SearchZoneMember(ctx *gin.Context, zid, memMid int64) (list []*dbstruct.ZoneMember, err error) {
list, err = v.store.SearchZoneMember(ctx, nil, zid, memMid)

View File

@ -1001,7 +1001,7 @@ func (s *Service) ZoneMemberList(ctx *gin.Context, req *vasproto.GetZoneMemberLi
return
}
func (s *Service) ZoneMemberListV2(ctx *gin.Context, req *vasproto.GetZoneMemberListV2Req) (list []*vasproto.ZoneMemberVo, ec errcode.ErrCode, err error) {
func (s *Service) ZoneMemberListV2(ctx *gin.Context, req *vasproto.GetZoneMemberListV2Req) (list []*vasproto.ZoneMemberVo, total int64, ec errcode.ErrCode, err error) {
list = make([]*vasproto.ZoneMemberVo, 0)
// 获取成员列表
@ -1028,6 +1028,9 @@ func (s *Service) ZoneMemberListV2(ctx *gin.Context, req *vasproto.GetZoneMember
}
list = append(list, tmp)
}
// 总数
total, _ = _DefaultVas.GetZoneMemberCnt(ctx, req.Zid, req.MemberType)
return
}