提交 1cc1de6e 编写于 作者: Q qq_36105691

fix

上级 0cfdceed
......@@ -14,24 +14,29 @@ namespace Mika {
exit(0);
}
if (command == "players") {
ResultPrinter::printPlayers(PlayerDAO::getAllPlayers(), os);
} else if (command.find("result") == std::string::npos) {
ResultPrinter::printError(os);
} else {
std::string matchName = command.substr(7);
try {
if (command == "players") {
ResultPrinter::printPlayers(PlayerDAO::getAllPlayers(), os);
} else if (command.find("result") == std::string::npos) {
ResultPrinter::printError(os);
} else {
std::string matchName = command.substr(7);
try {
if (command.find("detail") != std::string::npos) {
auto matches = MatchDAO::getMatchDetailsByName(matchName.substr(0, matchName.size() - 7));
matches.empty() ? ResultPrinter::printNA(os) : ResultPrinter::printMatchResultsDetail(matches, os);
} else {
auto matches = MatchDAO::getMatchesByName(matchName);
matches.empty() ? ResultPrinter::printNA(os) : ResultPrinter::printMatchResults(matches, os);
try {
if (command.find("detail") != std::string::npos) {
auto matches = MatchDAO::getMatchDetailsByName(matchName.substr(0, matchName.size() - 7));
matches.empty() ? ResultPrinter::printNA(os) : ResultPrinter::printMatchResultsDetail(matches,
os);
} else {
auto matches = MatchDAO::getMatchesByName(matchName);
matches.empty() ? ResultPrinter::printNA(os) : ResultPrinter::printMatchResults(matches, os);
}
} catch (std::exception &) {
ResultPrinter::printNA(os);
}
} catch (std::exception) {
ResultPrinter::printNA(os);
}
} catch (std::exception &e) {
LOG_ERROR(e.what());
}
}
} // Mika
\ No newline at end of file
......@@ -20,6 +20,8 @@ namespace Mika {
}
void UserInput::getInput(int argc, char **argv) {
std::ios::sync_with_stdio(false);
if (argc == 1) {
getInput();
return;
......@@ -39,7 +41,7 @@ namespace Mika {
}
}
std::vector<std::string> UserInput::readInputFile(std::string filename) {
std::vector<std::string> UserInput::readInputFile(const std::string &filename) {
std::vector<std::string> commands;
std::fstream file(filename);
......
......@@ -24,7 +24,7 @@ namespace Mika {
static void getInput(int argc, char *argv[]);
static std::vector<std::string> readInputFile(std::string filename);
static std::vector<std::string> readInputFile(const std::string &filename);
};
} // Mika
......
......@@ -8,7 +8,7 @@
namespace Mika {
std::vector<Player> PlayerDAO::getAllPlayers() {
auto db = DatabaseManager::getInstance();
constexpr auto query = "SELECT * FROM player";
constexpr auto query = R"(SELECT * FROM player ORDER BY country ASC, last_name ASC)";
return db->executeQuery<Player>(query);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册