This commit is contained in:
aozhiwei 2021-12-03 19:49:28 +08:00
parent 3e86b80f1b
commit f51b66f84a
4 changed files with 32 additions and 38 deletions

View File

@ -9,14 +9,14 @@ void JsonDataMgr::Init()
{
if (!f8::IsOnlineEnv()) {
if (f8::IsTestEnv()) {
work_path_ = a8::Format("/root/pub/%d/%d/conf_test/game%d/rankserver.test",
work_path_ = a8::Format("/root/pub/%d/%d/conf_test/game%d/textserver.test",
{
GAME_ID,
App::Instance()->instance_id,
GAME_ID
});
} else {
work_path_ = a8::Format("/root/pub/%d/%d/conf_test/game%d/rankserver.dev",
work_path_ = a8::Format("/root/pub/%d/%d/conf_test/game%d/textserver.dev",
{
GAME_ID,
App::Instance()->instance_id,
@ -24,19 +24,12 @@ void JsonDataMgr::Init()
});
}
}
std::string rankserver_cluster_json_file;
std::string mysql_cluster_json_file;
mysql_cluster_json_file = a8::Format("%s/node1/friend.rankserver.mysql.cluster.json",
{
work_path_,
});
rankserver_cluster_json_file = a8::Format("%s/node1/friend.rankserver.cluster.json",
{
work_path_,
});
rankserver_cluster_json_.ReadFromFile(rankserver_cluster_json_file);
mysql_cluster_json_.ReadFromFile(mysql_cluster_json_file);
std::string textserver_cluster_json_file;
textserver_cluster_json_file = a8::Format("%s/textserver.cluster.json",
{
work_path_,
});
textserver_cluster_json_.ReadFromFile(textserver_cluster_json_file);
}
void JsonDataMgr::UnInit()
@ -45,18 +38,8 @@ void JsonDataMgr::UnInit()
std::shared_ptr<a8::XObject> JsonDataMgr::GetConf()
{
if (App::Instance()->instance_id < 1 || App::Instance()->instance_id > rankserver_cluster_json_.Size()) {
if (App::Instance()->instance_id < 1 || App::Instance()->instance_id > textserver_cluster_json_.Size()) {
abort();
}
return rankserver_cluster_json_[App::Instance()->instance_id - 1];
}
std::shared_ptr<a8::XObject> JsonDataMgr::GetMysqlClusterConf()
{
return std::make_shared<a8::XObject>(mysql_cluster_json_);
}
std::shared_ptr<a8::XObject> JsonDataMgr::GetMysqlConf(int instance_id)
{
return mysql_cluster_json_[instance_id - 1];
return textserver_cluster_json_[App::Instance()->instance_id - 1];
}

View File

@ -10,12 +10,9 @@ class JsonDataMgr : public a8::Singleton<JsonDataMgr>
void Init();
void UnInit();
std::shared_ptr<a8::XObject> GetMysqlClusterConf();
std::shared_ptr<a8::XObject> GetConf();
std::shared_ptr<a8::XObject> GetMysqlConf(int instance_id);
private:
std::string work_path_ = "../config";
a8::XObject mysql_cluster_json_;
a8::XObject rankserver_cluster_json_;
a8::XObject textserver_cluster_json_;
};

View File

@ -41,20 +41,18 @@ public:
{
if (!f8::IsOnlineEnv()) {
if (f8::IsTestEnv()) {
res_path = a8::Format("/root/pub/%d/%d/conf_test/game%d/rankserver.test/res%d/",
res_path = a8::Format("/root/pub/%d/%d/conf_test/game%d/res/",
{
GAME_ID,
App::Instance()->instance_id,
GAME_ID,
App::Instance()->instance_id
});
} else {
res_path = a8::Format("/root/pub/%d/%d/conf_test/game%d/rankserver.dev/res%d/",
res_path = a8::Format("/root/pub/%d/%d/conf_test/game%d/res/",
{
GAME_ID,
App::Instance()->instance_id,
GAME_ID,
App::Instance()->instance_id
});
}
} else {

View File

@ -26,12 +26,22 @@ void TextMgr::UnInit()
void TextMgr::__DirtyWordCheck(f8::JsonHttpRequest* request)
{
request->resp_xobj->SetVal("errcode", 0);
request->resp_xobj->SetVal("errmsg", "");
std::string text = request->request.At("text")->AsXValue();
if (MetaMgr::Instance()->HasDirtyWord(text)) {
request->resp_xobj->SetVal("errcode", 1);
request->resp_xobj->SetVal("errmsg", "含有屏蔽字符");
}
}
void TextMgr::__DirtyWordReplace(f8::JsonHttpRequest* request)
{
std::string text = request->request.At("text")->AsXValue();
std::string new_text = MetaMgr::Instance()->ReplaceDirtyWord(text, '*');
request->resp_xobj->SetVal("errcode", 0);
request->resp_xobj->SetVal("errmsg", "");
request->resp_xobj->SetVal("new_text", new_text);
}
void TextMgr::__RandName(f8::JsonHttpRequest* request)
@ -41,5 +51,11 @@ void TextMgr::__RandName(f8::JsonHttpRequest* request)
void TextMgr::__IsValidName(f8::JsonHttpRequest* request)
{
request->resp_xobj->SetVal("errcode", 0);
request->resp_xobj->SetVal("errmsg", "");
std::string name = request->request.At("name")->AsXValue();
if (MetaMgr::Instance()->HasDirtyWord(name)) {
request->resp_xobj->SetVal("errcode", 1);
request->resp_xobj->SetVal("errmsg", "含有屏蔽字符");
}
}