mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralsec.git
synced 2025-11-01 11:17:51 +00:00
Adding filters on retrieving users/subscribers.
This commit is contained in:
@@ -13,11 +13,23 @@ namespace OpenWifi {
|
||||
std::vector<SecurityObjects::UserInfo> Users;
|
||||
bool IdOnly = (GetParameter("idOnly","false")=="true");
|
||||
auto operatorId = GetParameter("operatorId");
|
||||
auto nameSearch = GetParameter("nameSearch");
|
||||
auto emailSearch = GetParameter("emailSearch");
|
||||
|
||||
std::string baseQuery;
|
||||
if(!nameSearch.empty() || !emailSearch.empty()) {
|
||||
if(!nameSearch.empty())
|
||||
baseQuery = fmt::format(" Lower(name) like('%{}%' ", Poco::toLower(nameSearch) );
|
||||
if(!emailSearch.empty())
|
||||
baseQuery += baseQuery.empty() ? fmt::format(" Lower(email) like('%{}%' ", Poco::toLower(emailSearch))
|
||||
: fmt::format(" and Lower(email) like('%{}%' ", Poco::toLower(emailSearch));
|
||||
}
|
||||
|
||||
if(QB_.CountOnly) {
|
||||
std::string whereClause;
|
||||
if(!operatorId.empty()) {
|
||||
whereClause = fmt::format(" owner='{}' ", operatorId);
|
||||
whereClause = baseQuery.empty() ? fmt::format(" owner='{}' ", operatorId) :
|
||||
fmt::format(" owner='{}' and {} ", operatorId, baseQuery);
|
||||
auto count = StorageService()->SubDB().Count(whereClause);
|
||||
return ReturnCountOnly(count);
|
||||
}
|
||||
@@ -28,7 +40,8 @@ namespace OpenWifi {
|
||||
Poco::JSON::Object Answer;
|
||||
std::string whereClause;
|
||||
if(!operatorId.empty()) {
|
||||
whereClause = fmt::format(" owner='{}' ", operatorId);
|
||||
whereClause = baseQuery.empty() ? fmt::format(" owner='{}' ", operatorId) :
|
||||
fmt::format(" owner='{}' and {} ", operatorId, baseQuery);
|
||||
}
|
||||
if (StorageService()->SubDB().GetUsers(QB_.Offset, QB_.Limit, Users, whereClause)) {
|
||||
for (auto &i : Users) {
|
||||
|
||||
Reference in New Issue
Block a user