total
This commit is contained in:
parent
eedc49b4b2
commit
afa4ef12db
|
@ -272,6 +272,7 @@ type GetZoneMemberListV2Data struct {
|
||||||
List []*ZoneMemberVo `json:"list"`
|
List []*ZoneMemberVo `json:"list"`
|
||||||
Offset int64 `json:"offset"`
|
Offset int64 `json:"offset"`
|
||||||
More int32 `json:"more"`
|
More int32 `json:"more"`
|
||||||
|
Total int64 `json:"total"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetZoneMemberListV2Resp struct {
|
type GetZoneMemberListV2Resp struct {
|
||||||
|
|
|
@ -142,7 +142,7 @@ func ZoneMemberListV2(ctx *gin.Context) {
|
||||||
ReplyErrCodeMsg(ctx, errcode.ErrCodeBadParam)
|
ReplyErrCodeMsg(ctx, errcode.ErrCodeBadParam)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
list, ec, err := service.DefaultService.ZoneMemberListV2(ctx, req)
|
list, total, ec, err := service.DefaultService.ZoneMemberListV2(ctx, req)
|
||||||
if ec != errcode.ErrCodeVasSrvOk {
|
if ec != errcode.ErrCodeVasSrvOk {
|
||||||
logger.Error("ZoneMemberList fail, req: %v, ec: %v", util.ToJson(req), ec)
|
logger.Error("ZoneMemberList fail, req: %v, ec: %v", util.ToJson(req), ec)
|
||||||
if ec == errcode.ErrCodeVasSrvFail && err != nil {
|
if ec == errcode.ErrCodeVasSrvFail && err != nil {
|
||||||
|
@ -155,6 +155,7 @@ func ZoneMemberListV2(ctx *gin.Context) {
|
||||||
data := &vasproto.GetZoneMemberListV2Data{
|
data := &vasproto.GetZoneMemberListV2Data{
|
||||||
List: list,
|
List: list,
|
||||||
Offset: req.Offset + int64(len(list)),
|
Offset: req.Offset + int64(len(list)),
|
||||||
|
Total: total,
|
||||||
}
|
}
|
||||||
if int64(len(list)) >= req.Limit {
|
if int64(len(list)) >= req.Limit {
|
||||||
data.More = 1
|
data.More = 1
|
||||||
|
|
|
@ -465,6 +465,31 @@ func (m *Mysql) GetZoneMemberListV2(ctx *gin.Context, tx *sqlx.Tx, zid, offset,
|
||||||
return
|
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) {
|
func (m *Mysql) SearchZoneMember(ctx *gin.Context, tx *sqlx.Tx, zid, memMid int64) (list []*dbstruct.ZoneMember, err error) {
|
||||||
list = make([]*dbstruct.ZoneMember, 0)
|
list = make([]*dbstruct.ZoneMember, 0)
|
||||||
|
|
|
@ -1006,6 +1006,15 @@ func (v *Vas) GetZoneMemberListV2(ctx *gin.Context, zid, offset, limit int64, me
|
||||||
return
|
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) {
|
func (v *Vas) SearchZoneMember(ctx *gin.Context, zid, memMid int64) (list []*dbstruct.ZoneMember, err error) {
|
||||||
list, err = v.store.SearchZoneMember(ctx, nil, zid, memMid)
|
list, err = v.store.SearchZoneMember(ctx, nil, zid, memMid)
|
||||||
|
|
|
@ -1001,7 +1001,7 @@ func (s *Service) ZoneMemberList(ctx *gin.Context, req *vasproto.GetZoneMemberLi
|
||||||
return
|
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)
|
list = make([]*vasproto.ZoneMemberVo, 0)
|
||||||
|
|
||||||
// 获取成员列表
|
// 获取成员列表
|
||||||
|
@ -1028,6 +1028,9 @@ func (s *Service) ZoneMemberListV2(ctx *gin.Context, req *vasproto.GetZoneMember
|
||||||
}
|
}
|
||||||
list = append(list, tmp)
|
list = append(list, tmp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 总数
|
||||||
|
total, _ = _DefaultVas.GetZoneMemberCnt(ctx, req.Zid, req.MemberType)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue