fix datetime and map type for qt5cpp

This commit is contained in:
wing328 2018-04-05 14:36:35 +08:00
parent d882ad2fcb
commit a4bcb3bc73
4 changed files with 21 additions and 6 deletions

View File

@ -1693,6 +1693,7 @@ public class DefaultCodegen implements CodegenConfig {
}
if (p instanceof DateSchema || SchemaTypeUtil.DATE_FORMAT.equals(p.getFormat())) {
property.isString = false; // for backward compatibility with 2.x
property.isDate = true;
if (p.getEnum() != null) {
List<String> _enum = p.getEnum();
@ -1710,6 +1711,7 @@ public class DefaultCodegen implements CodegenConfig {
}
if (p instanceof DateTimeSchema || SchemaTypeUtil.DATE_TIME_FORMAT.equals(p.getFormat())) {
property.isString = false; // for backward compatibility with 2.x
property.isDateTime = true;
if (p.getEnum() != null) {
List<String> _enum = p.getEnum();

View File

@ -220,7 +220,24 @@ bool
bool isObjectUpdated = false;
do{
{{#vars}}
{{#isPrimitiveType}}if(m_{{name}}_isSet){ isObjectUpdated = true; break;}{{/isPrimitiveType}}{{#isContainer}}if({{name}}->size() > 0){ isObjectUpdated = true; break;}{{/isContainer}}{{^isContainer}}{{#complexType}}{{^isString}}{{^isDateTime}}if({{name}} != nullptr && {{name}}->isSet()){ isObjectUpdated = true; break;}{{/isDateTime}}{{/isString}}{{#isString}}if({{name}} != nullptr && *{{name}} != QString("")){ isObjectUpdated = true; break;}{{/isString}}{{/complexType}}{{/isContainer}}
{{#isPrimitiveType}}
if(m_{{name}}_isSet){ isObjectUpdated = true; break;}
{{/isPrimitiveType}}
{{#isContainer}}
if({{name}}->size() > 0){ isObjectUpdated = true; break;}
{{/isContainer}}
{{^isContainer}}
{{#complexType}}
{{^isString}}
{{^isDateTime}}
if({{name}} != nullptr && {{name}}->isSet()){ isObjectUpdated = true; break;}
{{/isDateTime}}
{{/isString}}
{{#isString}}
if({{name}} != nullptr && *{{name}} != QString("")){ isObjectUpdated = true; break;}
{{/isString}}
{{/complexType}}
{{/isContainer}}
{{/vars}}
}while(false);
return isObjectUpdated;

View File

@ -111,9 +111,6 @@ SWGOrder::asJsonObject() {
if(m_quantity_isSet){
obj.insert("quantity", QJsonValue(quantity));
}
if(ship_date != nullptr && *ship_date != QString("")){
toJsonValue(QString("shipDate"), ship_date, obj, QString("QDateTime"));
}
if(ship_date != nullptr) {
toJsonValue(QString("shipDate"), ship_date, obj, QString("QDateTime"));
}
@ -195,7 +192,6 @@ SWGOrder::isSet(){
if(m_id_isSet){ isObjectUpdated = true; break;}
if(m_pet_id_isSet){ isObjectUpdated = true; break;}
if(m_quantity_isSet){ isObjectUpdated = true; break;}
if(ship_date != nullptr && *ship_date != QString("")){ isObjectUpdated = true; break;}
if(status != nullptr && *status != QString("")){ isObjectUpdated = true; break;}
if(m_complete_isSet){ isObjectUpdated = true; break;}
}while(false);

View File

@ -119,7 +119,7 @@ SWGStoreApi::getInventoryCallback(SWGHttpRequestWorker * worker) {
msg = "Error: " + worker->error_str;
}
QMap<QString, qint32>* output = NULL;
QMap<QString, qint32>* output = new QMap<QString, qint32>();
QString json(worker->response);
QByteArray array (json.toStdString().c_str());
QJsonDocument doc = QJsonDocument::fromJson(array);