Commit fa5b2639 authored by Keliang's avatar Keliang

cmcc udr support multi ue up to 100

parent 82273252
...@@ -14,8 +14,10 @@ ...@@ -14,8 +14,10 @@
#include "AuthenticationSubscriptionDocumentApiImpl.h" #include "AuthenticationSubscriptionDocumentApiImpl.h"
#include "PatchResult.h" #include "PatchResult.h"
#include "logger.hpp" #include "logger.hpp"
#include "udr_config.hpp"
#include <AuthenticationSubscription.h> #include <AuthenticationSubscription.h>
using namespace config;
extern udr_config udr_cfg;
namespace org { namespace org {
namespace openapitools { namespace openapitools {
...@@ -37,6 +39,17 @@ void AuthenticationSubscriptionDocumentApiImpl:: ...@@ -37,6 +39,17 @@ void AuthenticationSubscriptionDocumentApiImpl::
const Pistache::Optional<std::string> &supportedFeatures, const Pistache::Optional<std::string> &supportedFeatures,
Pistache::Http::ResponseWriter &response) { Pistache::Http::ResponseWriter &response) {
MYSQL mudsf;
mysql_init(&mudsf);
if (!mysql_real_connect(&mudsf, udr_cfg.mysql.mysql_server.c_str(),
udr_cfg.mysql.mysql_user.c_str(),
udr_cfg.mysql.mysql_pass.c_str(),
udr_cfg.mysql.mysql_db.c_str(), udr_cfg.mysql.mysql_port, 0, 0)) {
Logger::udr_app().error("An error occurred while connecting to db: %s",
mysql_error(&mudsf));
return ;
}
MYSQL_RES *res = NULL; MYSQL_RES *res = NULL;
MYSQL_ROW row; MYSQL_ROW row;
...@@ -54,16 +67,16 @@ void AuthenticationSubscriptionDocumentApiImpl:: ...@@ -54,16 +67,16 @@ void AuthenticationSubscriptionDocumentApiImpl::
.get_to(sequencenumber); .get_to(sequencenumber);
if (mysql_real_query( if (mysql_real_query(
mysql_WitcommUDRDB, select_Authenticationsubscription.c_str(), &mudsf, select_Authenticationsubscription.c_str(),
(unsigned long)select_Authenticationsubscription.size())) { (unsigned long)select_Authenticationsubscription.size())) {
Logger::udr_server().error("mysql_real_query failureSQL(%s)", Logger::udr_server().error("mysql_real_query failure MYSQL(%s)",
select_Authenticationsubscription.c_str()); select_Authenticationsubscription.c_str());
return; return;
} }
res = mysql_store_result(mysql_WitcommUDRDB); res = mysql_store_result(&mudsf);
if (res == NULL) { if (res == NULL) {
Logger::udr_server().error("mysql_store_result failureSQL(%s)", Logger::udr_server().error("mysql_store_result failure MYSQL(%s)",
select_Authenticationsubscription.c_str()); select_Authenticationsubscription.c_str());
return; return;
} }
...@@ -84,7 +97,7 @@ void AuthenticationSubscriptionDocumentApiImpl:: ...@@ -84,7 +97,7 @@ void AuthenticationSubscriptionDocumentApiImpl::
// Logger::udr_server().debug("modify content: // Logger::udr_server().debug("modify content:
// %s",query.c_str()); // %s",query.c_str());
if (mysql_real_query(mysql_WitcommUDRDB, query.c_str(), if (mysql_real_query(&mudsf, query.c_str(),
(unsigned long)query.size())) { (unsigned long)query.size())) {
Logger::udr_server().error("update mysql failure!SQL(%s)", Logger::udr_server().error("update mysql failure!SQL(%s)",
query.c_str()); query.c_str());
...@@ -108,6 +121,16 @@ void AuthenticationSubscriptionDocumentApiImpl:: ...@@ -108,6 +121,16 @@ void AuthenticationSubscriptionDocumentApiImpl::
const std::string &ueId, const std::string &ueId,
const Pistache::Optional<std::string> &supportedFeatures, const Pistache::Optional<std::string> &supportedFeatures,
Pistache::Http::ResponseWriter &response) { Pistache::Http::ResponseWriter &response) {
MYSQL mudsf;
mysql_init(&mudsf);
if (!mysql_real_connect(&mudsf, udr_cfg.mysql.mysql_server.c_str(),
udr_cfg.mysql.mysql_user.c_str(),
udr_cfg.mysql.mysql_pass.c_str(),
udr_cfg.mysql.mysql_db.c_str(), udr_cfg.mysql.mysql_port, 0, 0)) {
Logger::udr_app().error("An error occurred while connecting to db: %s",
mysql_error(&mudsf));
return ;
}
MYSQL_RES *res = NULL; MYSQL_RES *res = NULL;
MYSQL_ROW row; MYSQL_ROW row;
MYSQL_FIELD *field = nullptr; MYSQL_FIELD *field = nullptr;
...@@ -118,14 +141,14 @@ void AuthenticationSubscriptionDocumentApiImpl:: ...@@ -118,14 +141,14 @@ void AuthenticationSubscriptionDocumentApiImpl::
const std::string query = const std::string query =
"select * from AuthenticationSubscription WHERE ueid='" + ueId + "'"; "select * from AuthenticationSubscription WHERE ueid='" + ueId + "'";
if (mysql_real_query(mysql_WitcommUDRDB, query.c_str(), if (mysql_real_query(&mudsf, query.c_str(),
(unsigned long)query.size())) { (unsigned long)query.size())) {
Logger::udr_server().error("mysql_real_query failure!SQL(%s)", Logger::udr_server().error("mysql_real_query failure!SQL(%s)",
query.c_str()); query.c_str());
return; return;
} }
res = mysql_store_result(mysql_WitcommUDRDB); res = mysql_store_result(&mudsf);
if (res == NULL) { if (res == NULL) {
Logger::udr_server().error("mysql_store_result failure!SQL(%s)", Logger::udr_server().error("mysql_store_result failure!SQL(%s)",
query.c_str()); query.c_str());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment