From 143483634bb5dec8add7754bd1e9f7c7b7ce9ed3 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 25 Sep 2020 10:45:03 +0800 Subject: [PATCH] 1 --- server/imserver/guild.cc | 92 +++++++++++++++++++++++++- server/tools/protobuild/cs_msgid.proto | 6 +- 2 files changed, 95 insertions(+), 3 deletions(-) diff --git a/server/imserver/guild.cc b/server/imserver/guild.cc index f6f77f6..e91aa0c 100644 --- a/server/imserver/guild.cc +++ b/server/imserver/guild.cc @@ -233,7 +233,97 @@ void Guild::_CMGuildMemberList(f8::MsgHdr& hdr, const cs::CMGuildMemberList& msg void Guild::_CMGuildApplyList(f8::MsgHdr& hdr, const cs::CMGuildApplyList& msg) { - cs::SMGuildApplyList respmsg; + auto on_ok = + [] (a8::XParams& param, const f8::DataSet* data_set) + { + cs::MFPaging* paging = (cs::MFPaging*)param.param2.GetUserData(); + #if 0 + Player* hum = PlayerMgr::Instance()->GetPlayerByAccountId(param.sender.GetString()); + if (hum && hum->socket_handle == param.param1.GetInt()) { + for (auto& row : *data_set) { + FriendApply* apply = new FriendApply; + apply->idx = a8::XValue(row[0]); + apply->applyid = a8::XValue(row[1]); + apply->target_id = row[2]; + apply->base_data.account_id = row[3]; + apply->base_data.nickname = row[4]; + apply->base_data.avatar_url = row[5]; + apply->base_data.sex = a8::XValue(row[6]); + apply->base_data.base_data_version = a8::XValue(row[7]); + apply->base_data.user_value1 = a8::XValue(row[8]); + apply->base_data.user_value2 = a8::XValue(row[9]); + apply->base_data.user_value3 = a8::XValue(row[10]); + hum->apply_hash_[apply->idx] = apply; + if (apply->idx > hum->last_apply_idx_) { + hum->last_apply_idx_ = apply->idx; + } + } + cs::SMFriendApplyList respmsg; + hum->FillApplyList(*paging, respmsg); + hum->SendMsg(respmsg); + a8::UnSetBitFlag(hum->red_point_flags_, RPF_Apply); + hum->SyncRedPoint(); + } + #endif + delete paging; + }; + auto on_error = + [] (a8::XParams& param, int error_code, const std::string& error_msg) + { + cs::MFPaging* paging = (cs::MFPaging*)param.param2.GetUserData(); + #if 0 + Player* hum = PlayerMgr::Instance()->GetPlayerByAccountId(param.sender.GetString()); + if (hum && hum->socket_handle == param.param1.GetInt()) { + cs::SMFriendApplyList respmsg; + hum->FillApplyList(*paging, respmsg); + hum->SendMsg(respmsg); + } + #endif + delete paging; + }; + + ss::SS_IM_ForwardGuildCMMsg *forward_msg = (ss::SS_IM_ForwardGuildCMMsg*)hdr.user_data; + + cs::MFPaging* paging_copy = new cs::MFPaging; + *paging_copy = msg.paging(); + #if 1 + paging_copy->set_curr_page(0); + paging_copy->set_page_size(20); + #endif + a8::XObject conn_info = DBEngine::Instance()->GetConnInfo(guild_id); + std::string fmtstr = "SELECT '' AS account_id"; + std::vector sql_params; + { + #if 0 + for (auto& pair : black_hash_) { + fmtstr += " UNION SELECT '%s'"; + sql_params.push_back(a8::XValue(pair.second->base_data.account_id)); + } + sql_params.push_back(a8::XValue(last_apply_idx_)); + sql_params.push_back(a8::XValue(myself.base_data.account_id)); + #endif + } + DBEngine::Instance()->ExecAsyncQuery + ( + conn_info, + ( + "SELECT A.idx, A.applyid, A.target_id, A.sender_id, A.sender_nickname, " + " A.sender_avatar_url, A.sender_sex, A.sender_data_version1, " + " A.sender_user_value1, A.sender_user_value2, A.sender_user_value3, A.status " + "FROM guild_apply A " + " LEFT JOIN (" + fmtstr + ") AS B ON B.account_id = A.sender_id " + "WHERE A.idx > %d AND A.target_id='%s' AND A.status=0 AND " + " B.account_id IS NULL;" + ).c_str(), + sql_params, + a8::XParams() + .SetSender(guild_id) + .SetParam1(0) + .SetParam2(paging_copy), + on_ok, + on_error, + guild_id + ); } void Guild::_CMGuildLog(f8::MsgHdr& hdr, const cs::CMGuildLog& msg) diff --git a/server/tools/protobuild/cs_msgid.proto b/server/tools/protobuild/cs_msgid.proto index 518c3a0..ed81826 100644 --- a/server/tools/protobuild/cs_msgid.proto +++ b/server/tools/protobuild/cs_msgid.proto @@ -45,7 +45,8 @@ enum CMMessageId_e _CMGuildSearch = 239; _CMGuildRank = 240; _CMGuildMemberList = 241; - _CMGuildLog = 242; + _CMGuildApplyList = 242; + _CMGuildLog = 243; _CMGuildMsgEnd = 270; } @@ -89,7 +90,8 @@ enum SMMessageId_e _SMGuildSearch = 239; _SMGuildRank = 240; _SMGuildMemberList = 241; - _SMGuildLog = 242; + _SMGuildApplyList = 242; + _SMGuildLog = 243; _SMGuildMsgEnd = 270; _SMUserStatusNotify = 501;