This commit is contained in:
aozhiwei 2020-09-17 20:02:29 +08:00
parent d204076325
commit b01e8159a1
3 changed files with 34 additions and 5 deletions

View File

@ -10,6 +10,7 @@
#include "app.h"
#include "guildmgr.h"
#include "typeconvert.h"
#include "utils.h"
void Guild::Init()
{
@ -151,11 +152,7 @@ void Guild::_CMGuildMemberList(int socket_handle, const ss::MFIMMsgConext& conte
if (respmsg.paging().page_size() <= 0) {
respmsg.mutable_paging()->set_page_size(10);
}
respmsg.mutable_paging()->set__total_page(std::ceil(sorted_members_.size() / respmsg.paging().page_size()));
respmsg.mutable_paging()->set__total_count(sorted_members_.size());
if (respmsg.paging().curr_page() >= respmsg.paging()._total_page()) {
respmsg.mutable_paging()->set_curr_page(respmsg.paging()._total_page());
}
AdjustPaging(respmsg.mutable_paging(), sorted_members_.size());
GuildMgr::Instance()->ForwardGuildSMMsg(socket_handle, context, respmsg);
}

24
server/imserver/utils.cc Normal file
View File

@ -0,0 +1,24 @@
#include "precompile.h"
#include "utils.h"
#include "cs_proto.pb.h"
#include "ss_proto.pb.h"
void AdjustPaging(cs::MFPaging* paging, int total_count)
{
paging->set__total_page(std::ceil(total_count / paging->page_size()));
paging->set__total_count(total_count);
if (paging->curr_page() >= paging->_total_page()) {
paging->set_curr_page(paging->_total_page());
}
if (paging->_total_page() <= 0) {
paging->set_curr_page(0);
} else {
if (paging->curr_page() < 0) {
paging->set_curr_page(0);
}
if (paging->curr_page() >= paging->_total_page()) {
paging->set_curr_page(paging->_total_page() - 1);
}
}
}

8
server/imserver/utils.h Normal file
View File

@ -0,0 +1,8 @@
#pragma once
namespace cs
{
class MFPaging;
}
void AdjustPaging(cs::MFPaging* paging, int total_count);