Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
hggq committed Dec 24, 2022
1 parent 618de9a commit 3cbeb23
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 49 deletions.
2 changes: 1 addition & 1 deletion orm/cms/Article.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ CREATE TABLE `article` (
`summary` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '文章摘要',
`editauthor` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '文章编辑',
PRIMARY KEY (`aid`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
30 changes: 15 additions & 15 deletions orm/cms/include/articlebase.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define ORM_CMS_ARTICLEBASEMATA_H
/*
*This file is auto create from cli
*本文件为自动生成 Fri, 23 Dec 2022 16:21:15 GMT
*本文件为自动生成 Sat, 24 Dec 2022 15:17:41 GMT
***/
#include <iostream>
#include <cstdio>
Expand Down Expand Up @@ -530,14 +530,14 @@ tempsql<<"null";
tempsql<<std::to_string(data.aid);
}
if(data.classtype==0){
tempsql<<"null";
tempsql<<",0";
}else{
tempsql<<std::to_string(data.classtype);
tempsql<<","<<std::to_string(data.classtype);
}
if(data.userid==0){
tempsql<<"null";
tempsql<<",0";
}else{
tempsql<<std::to_string(data.userid);
tempsql<<","<<std::to_string(data.userid);
}
tempsql<<",'"<<stringaddslash(data.title)<<"'";
tempsql<<",'"<<stringaddslash(data.keywords)<<"'";
Expand All @@ -546,31 +546,31 @@ tempsql<<",'"<<stringaddslash(data.author)<<"'";
tempsql<<",'"<<stringaddslash(data.addip)<<"'";
tempsql<<",'"<<stringaddslash(data.createtime)<<"'";
if(data.addtime==0){
tempsql<<"null";
tempsql<<",0";
}else{
tempsql<<std::to_string(data.addtime);
tempsql<<","<<std::to_string(data.addtime);
}
if(data.readnum==0){
tempsql<<"null";
tempsql<<",0";
}else{
tempsql<<std::to_string(data.readnum);
tempsql<<","<<std::to_string(data.readnum);
}
if(data.review==0){
tempsql<<"null";
tempsql<<",0";
}else{
tempsql<<std::to_string(data.review);
tempsql<<","<<std::to_string(data.review);
}
tempsql<<",'"<<stringaddslash(data.icoimg)<<"'";
tempsql<<",'"<<stringaddslash(data.content)<<"'";
if(data.isopen==0){
tempsql<<"null";
tempsql<<",0";
}else{
tempsql<<std::to_string(data.isopen);
tempsql<<","<<std::to_string(data.isopen);
}
if(data.iscomment==0){
tempsql<<"null";
tempsql<<",0";
}else{
tempsql<<std::to_string(data.iscomment);
tempsql<<","<<std::to_string(data.iscomment);
}
tempsql<<",'"<<stringaddslash(data.fromlocal)<<"'";
tempsql<<",'"<<stringaddslash(data.texturl)<<"'";
Expand Down
10 changes: 5 additions & 5 deletions orm/cms/include/userbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define ORM_CMS_USERBASEMATA_H
/*
*This file is auto create from cli
*本文件为自动生成 Fri, 23 Dec 2022 16:21:15 GMT
*本文件为自动生成 Sat, 24 Dec 2022 15:17:41 GMT
***/
#include <iostream>
#include <cstdio>
Expand Down Expand Up @@ -238,14 +238,14 @@ tempsql<<"null";
tempsql<<",'"<<stringaddslash(data.name)<<"'";
tempsql<<",'"<<stringaddslash(data.password)<<"'";
if(data.isopen==0){
tempsql<<"null";
tempsql<<",0";
}else{
tempsql<<std::to_string(data.isopen);
tempsql<<","<<std::to_string(data.isopen);
}
if(data.level==0){
tempsql<<"null";
tempsql<<",0";
}else{
tempsql<<std::to_string(data.level);
tempsql<<","<<std::to_string(data.level);
}
tempsql<<")";

Expand Down
85 changes: 79 additions & 6 deletions vendor/httpcli/modelfun.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1471,25 +1471,98 @@ struct )";
{
if(table_type[j]!=7)
{
if(j==0)
{
if(tablecollist[j]==tablepkname)
{
insertstrem << "if(data." << tablecollist[j] << "==0){\n";
insertstrem << "tempsql<<\"null\";\n";
insertstrem << " }else{ \n";
insertstrem << "\ttempsql<<std::to_string(data." << tablecollist[j] << ");\n";
insertstrem << "}\n";
}
else
{
insertstrem << "if(data." << tablecollist[j] << "==0){\n";
insertstrem << "\ttempsql<<\"0\";\n";
insertstrem << " }else{ \n";
insertstrem << "\ttempsql<<std::to_string(data." << tablecollist[j] << ");\n";
insertstrem << "}\n";
}
}
else
{
if(tablecollist[j]==tablepkname)
{
insertstrem << "if(data." << tablecollist[j] << "==0){\n";
insertstrem << "tempsql<<\",null\";\n";
insertstrem << " }else{ \n";
insertstrem << "\ttempsql<<\",\"<<std::to_string(data." << tablecollist[j] << ");\n";
insertstrem << "}\n";
}
else
{
insertstrem << "if(data." << tablecollist[j] << "==0){\n";
insertstrem << "\ttempsql<<\",0\";\n";
insertstrem << " }else{ \n";
insertstrem << "\ttempsql<<\",\"<<std::to_string(data." << tablecollist[j] << ");\n";
insertstrem << "}\n";
}
}


continue;
}

}
// 数字
if (j == 0)
{
if(tablecollist[j]==tablepkname)
{
insertstrem << "if(data." << tablecollist[j] << "==0){\n";
insertstrem << "tempsql<<\"null\";\n";
insertstrem << " }else{ \n";
insertstrem << "\ttempsql<<std::to_string(data." << tablecollist[j] << ");\n";
insertstrem << "}\n";
}
else
{
if (colltypeshuzi[j] < 30)
{
insertstrem << "if(data." << tablecollist[j] << "==0){\n";
insertstrem << "\ttempsql<<\"0\";\n";
insertstrem << " }else{ \n";
insertstrem << "\ttempsql<<\"\"<<std::to_string(data." << tablecollist[j] << ");\n";
insertstrem << "}\n";
}
else if (colltypeshuzi[j] == 60)
{
insertstrem << " \nif(data." << tablecollist[j] << ".size()==0){ \n";
insertstrem << "tempsql<<\" CURRENT_TIMESTAMP \";\n";
insertstrem << " }else{ \n tempsql<<\"'\"<<data." << tablecollist[j] << "<<\"'\";\n }\n";
}
else if (colltypeshuzi[j] == 61)
{
insertstrem << " \nif(data." << tablecollist[j] << ".size()==0){ \n";
insertstrem << "tempsql<<\"CURRENT_DATE \";\n";
insertstrem << " }else{ \n tempsql<<\"'\"<<data." << tablecollist[j] << "<<\"'\";\n }\n";
}
else
{

insertstrem << "tempsql<<\"'\"<<stringaddslash(data." << tablecollist[j] << ")<<\"'\";\n";
}
}

continue;
}

}
if (colltypeshuzi[j] < 30)
{
insertstrem << "if(data." << tablecollist[j] << "==0){\n";

insertstrem << "\ttempsql<<\",0\";\n";

insertstrem << " }else{ \n";

insertstrem << "\ttempsql<<\",\"<<std::to_string(data." << tablecollist[j] << ");\n";

insertstrem << "}\n";
}
else if (colltypeshuzi[j] == 60)
Expand Down
43 changes: 21 additions & 22 deletions vendor/httpserver/include/mysqlmodel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace orm
std::unique_ptr<MYSQL, decltype(&mysql_close)> conn = http::get_mysqlselectexecute(dbhash);
MYSQL_RES *resultone = nullptr;
mysql_ping(conn.get());
int readnum = mysql_query(conn.get(), &countsql[0]);
long long readnum = mysql_real_query(conn.get(), &sqlstring[0],sqlstring.size());

if (readnum != 0)
{
Expand Down Expand Up @@ -164,9 +164,9 @@ namespace orm

try
{
std::unique_ptr<MYSQL, decltype(&mysql_close)> conn = http::get_mysqlselectexecute(dbhash);
std::unique_ptr<MYSQL, decltype(&mysql_close)> conn = http::get_mysqleditexecute(dbhash);
mysql_ping(conn.get());
long long readnum = mysql_query(conn.get(), &countsql[0]);
long long readnum = mysql_real_query(conn.get(), &sqlstring[0],sqlstring.size());
readnum = mysql_affected_rows(conn.get());
try
{
Expand Down Expand Up @@ -1285,7 +1285,7 @@ namespace orm
std::unique_ptr<MYSQL, decltype(&mysql_close)> conn = http::get_mysqlselectexecute(dbhash);
MYSQL_RES *resultall = nullptr;
mysql_ping(conn.get());
int readnum = mysql_query(conn.get(), &sqlstring[0]);
long long readnum = mysql_real_query(conn.get(), &sqlstring[0],sqlstring.size());

if (readnum != 0)
{
Expand Down Expand Up @@ -1390,7 +1390,7 @@ namespace orm
std::unique_ptr<MYSQL, decltype(&mysql_close)> conn = http::get_mysqlselectexecute(dbhash);
MYSQL_RES *resultall = nullptr;
mysql_ping(conn.get());
int readnum = mysql_query(conn.get(), &sqlstring[0]);
long long readnum = mysql_real_query(conn.get(), &sqlstring[0],sqlstring.size());

if (readnum != 0)
{
Expand Down Expand Up @@ -1506,7 +1506,7 @@ namespace orm
std::unique_ptr<MYSQL, decltype(&mysql_close)> conn = http::get_mysqlselectexecute(dbhash);
MYSQL_RES *resultall = nullptr;
mysql_ping(conn.get());
int readnum = mysql_query(conn.get(), &sqlstring[0]);
long long readnum = mysql_real_query(conn.get(), &sqlstring[0],sqlstring.size());

if (readnum != 0)
{
Expand Down Expand Up @@ -1642,7 +1642,7 @@ namespace orm
std::unique_ptr<MYSQL, decltype(&mysql_close)> conn = http::get_mysqlselectexecute(dbhash);
MYSQL_RES *resultall = nullptr;
mysql_ping(conn.get());
int readnum = mysql_query(conn.get(), &sqlstring[0]);
long long readnum = mysql_real_query(conn.get(), &sqlstring[0],sqlstring.size());

if (readnum != 0)
{
Expand Down Expand Up @@ -1721,7 +1721,7 @@ namespace orm
std::unique_ptr<MYSQL, decltype(&mysql_close)> conn = http::get_mysqlselectexecute(dbhash);
MYSQL_RES *resultone = nullptr;
mysql_ping(conn.get());
int readnum = mysql_query(conn.get(), &sqlstring[0]);
long long readnum = mysql_real_query(conn.get(), &sqlstring[0],sqlstring.size());

if (readnum != 0)
{
Expand Down Expand Up @@ -1806,9 +1806,9 @@ namespace orm
}
try
{
std::unique_ptr<MYSQL, decltype(&mysql_close)> conn = http::get_mysqlselectexecute(dbhash);
std::unique_ptr<MYSQL, decltype(&mysql_close)> conn = http::get_mysqleditexecute(dbhash);
mysql_ping(conn.get());
long long readnum = mysql_query(conn.get(), &sqlstring[0]);
long long readnum = mysql_real_query(conn.get(), &sqlstring[0],sqlstring.size());
readnum = mysql_affected_rows(conn.get());
try
{
Expand Down Expand Up @@ -1856,9 +1856,9 @@ namespace orm
}
try
{
std::unique_ptr<MYSQL, decltype(&mysql_close)> conn = http::get_mysqlselectexecute(dbhash);
std::unique_ptr<MYSQL, decltype(&mysql_close)> conn = http::get_mysqleditexecute(dbhash);
mysql_ping(conn.get());
long long readnum = mysql_query(conn.get(), &sqlstring[0]);
long long readnum = mysql_real_query(conn.get(), &sqlstring[0],sqlstring.size());
readnum = mysql_affected_rows(conn.get());
try
{
Expand Down Expand Up @@ -1904,9 +1904,9 @@ namespace orm
}
try
{
std::unique_ptr<MYSQL, decltype(&mysql_close)> conn = http::get_mysqlselectexecute(dbhash);
std::unique_ptr<MYSQL, decltype(&mysql_close)> conn = http::get_mysqleditexecute(dbhash);
mysql_ping(conn.get());
long long readnum = mysql_query(conn.get(), &sqlstring[0]);
long long readnum = mysql_real_query(conn.get(), &sqlstring[0],sqlstring.size());
readnum = mysql_affected_rows(conn.get());
try
{
Expand Down Expand Up @@ -1937,9 +1937,9 @@ namespace orm

try
{
std::unique_ptr<MYSQL, decltype(&mysql_close)> conn = http::get_mysqlselectexecute(dbhash);
std::unique_ptr<MYSQL, decltype(&mysql_close)> conn = http::get_mysqleditexecute(dbhash);
mysql_ping(conn.get());
long long readnum = mysql_query(conn.get(), &sqlstring[0]);
long long readnum = mysql_real_query(conn.get(), &sqlstring[0],sqlstring.size());
readnum = mysql_affected_rows(conn.get());
try
{
Expand Down Expand Up @@ -1991,10 +1991,9 @@ namespace orm

try
{
std::unique_ptr<MYSQL, decltype(&mysql_close)> conn = http::get_mysqlselectexecute(dbhash);
std::unique_ptr<MYSQL, decltype(&mysql_close)> conn = http::get_mysqleditexecute(dbhash);
mysql_ping(conn.get());
long long readnum = mysql_query(conn.get(), &sqlstring[0]);

long long readnum = mysql_real_query(conn.get(), &sqlstring[0],sqlstring.size());
if (readnum != 0)
{
error_msg = std::string(mysql_error(conn.get()));
Expand Down Expand Up @@ -2029,10 +2028,10 @@ namespace orm

try
{
std::unique_ptr<MYSQL, decltype(&mysql_close)> conn = http::get_mysqlselectexecute(dbhash);
sqlstring = base::_makeinsertsql();
std::unique_ptr<MYSQL, decltype(&mysql_close)> conn = http::get_mysqleditexecute(dbhash);
mysql_ping(conn.get());
long long readnum = mysql_query(conn.get(), &sqlstring[0]);

long long readnum = mysql_real_query(conn.get(), &sqlstring[0],sqlstring.size());
if (readnum != 0)
{
error_msg = std::string(mysql_error(conn.get()));
Expand Down

0 comments on commit 3cbeb23

Please sign in to comment.