Modify the model generator for time-type columns

This commit is contained in:
antao 2018-12-02 22:43:23 +08:00
parent 458d14591b
commit 52546b7846
2 changed files with 4 additions and 4 deletions

View File

@ -315,9 +315,9 @@ Json::Value {{className}}::toJson() const
if(get<%c++$$<<col._colTypeName;%>())
{
<%c++if(col._colDatabaseType=="date"){%>
ret["<%c++$$<<col._colName;%>"]=get<%c++$$<<col._colTypeName;%>()->toCustomedFormattedStringLocal("%Y-%m-%d", false);
ret["<%c++$$<<col._colName;%>"]=get<%c++$$<<col._colTypeName;%>()->toDbStringLocal();
<%c++}else if(col._colDatabaseType.find("timestamp")!=std::string::npos||col._colDatabaseType.find("datetime")!=std::string::npos){%>
ret["<%c++$$<<col._colName;%>"]=get<%c++$$<<col._colTypeName;%>()->toCustomedFormattedStringLocal("%Y-%m-%d %H:%M:%S", true);
ret["<%c++$$<<col._colName;%>"]=get<%c++$$<<col._colTypeName;%>()->toDbStringLocal();
<%c++}else if(col._colDatabaseType=="bytea"||col._colDatabaseType.find("blob")!=std::string::npos){%>
ret["<%c++$$<<col._colName;%>"]=drogon::base64Encode((const unsigned char *)get<%c++$$<<col._colTypeName;%>()->data(),get<%c++$$<<col._colTypeName;%>()->size());
<%c++}else if(col._colType=="int64_t"){%>

View File

@ -350,11 +350,11 @@ class SqlBinder
}
self &operator<<(trantor::Date &&date)
{
return operator<<(date.toCustomedFormattedStringLocal("%Y-%m-%d %H:%M:%S", true));
return operator<<(date.toDbStringLocal());
}
self &operator<<(const trantor::Date &date)
{
return operator<<(date.toCustomedFormattedStringLocal("%Y-%m-%d %H:%M:%S", true));
return operator<<(date.toDbStringLocal());
}
self &operator<<(const std::vector<char> &v)
{