Framework update.

This commit is contained in:
stephb9959
2022-05-19 16:09:28 -07:00
parent 428639c879
commit 4abec884bf
5 changed files with 30 additions and 5 deletions

2
build
View File

@@ -1 +1 @@
124 125

View File

@@ -2071,6 +2071,13 @@ paths:
type: string type: string
example: serialNumber:a,created:d example: serialNumber:a,created:d
required: false required: false
- in: query
description: return extended information
name: orderSpec
schema:
type: boolean
default: false
required: false
- in: query - in: query
description: return the list of devices under RRM description: return the list of devices under RRM
name: rrmOnly name: rrmOnly
@@ -2095,6 +2102,7 @@ paths:
- $ref: '#/components/schemas/SerialNumberList' - $ref: '#/components/schemas/SerialNumberList'
- $ref: '#/components/schemas/InventoryTagList' - $ref: '#/components/schemas/InventoryTagList'
- $ref: '#/components/schemas/CountAnswer' - $ref: '#/components/schemas/CountAnswer'
- $ref: '#/components/schemas/StringList'
400: 400:
$ref: '#/components/responses/BadRequest' $ref: '#/components/responses/BadRequest'
403: 403:

View File

@@ -662,4 +662,11 @@ namespace OpenWifi {
} }
} }
template <typename DBType> void ReturnFieldList(DBType & DB, RESTAPIHandler &H) {
Types::StringVec Fields;
DB.GetFieldNames(Fields);
Poco::JSON::Object Answer;
RESTAPI_utils::field_to_json(Answer,"list",Fields);
return H.ReturnObject(Answer);
}
} }

View File

@@ -34,11 +34,16 @@ namespace OpenWifi{
} }
void RESTAPI_inventory_list_handler::DoGet() { void RESTAPI_inventory_list_handler::DoGet() {
std::string UUID;
std::string Arg,Arg2; if(GetBoolParameter("orderSpec")) {
return ReturnFieldList(DB_,*this);
}
bool SerialOnly=GetBoolParameter("serialOnly"); bool SerialOnly=GetBoolParameter("serialOnly");
std::string UUID;
std::string Arg,Arg2;
std::string OrderBy{" ORDER BY serialNumber ASC "}; std::string OrderBy{" ORDER BY serialNumber ASC "};
if(HasParameter("orderBy",Arg)) { if(HasParameter("orderBy",Arg)) {
if(!DB_.PrepareOrderBy(Arg,OrderBy)) { if(!DB_.PrepareOrderBy(Arg,OrderBy)) {

View File

@@ -688,7 +688,7 @@ namespace ORM {
} }
if(!ItemList.empty()) if(!ItemList.empty())
ItemList += " , "; ItemList += " , ";
auto hint = FieldNames_.find(T[0]); auto hint = FieldNames_.find(Poco::toLower(T[0]));
if(hint==FieldNames_.end()) { if(hint==FieldNames_.end()) {
return false; return false;
} }
@@ -898,12 +898,17 @@ namespace ORM {
Poco::Logger & Logger() { return Logger_; } Poco::Logger & Logger() { return Logger_; }
bool DeleteRecordsFromCache(const char *FieldName, const std::string &Value ) { inline bool DeleteRecordsFromCache(const char *FieldName, const std::string &Value ) {
if(Cache_) if(Cache_)
Cache_->Delete(FieldName, Value); Cache_->Delete(FieldName, Value);
return true; return true;
} }
inline void GetFieldNames( OpenWifi::Types::StringVec & F) {
for(const auto &[field,_]:FieldNames_)
F.push_back(field);
}
protected: protected:
std::string TableName_; std::string TableName_;
OpenWifi::DBType Type_; OpenWifi::DBType Type_;