Skip to content

Commit

Permalink
fix orm to_tree
Browse files Browse the repository at this point in the history
  • Loading branch information
hggq committed Mar 12, 2024
1 parent cd6219d commit c8cf90b
Show file tree
Hide file tree
Showing 16 changed files with 74 additions and 104 deletions.
2 changes: 1 addition & 1 deletion orm/_rawsqlfile/cms_Article.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ CREATE TABLE `article` (
`editauthor` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '文章编辑',
`relatecontent` varchar(256) COLLATE utf8mb4_general_ci NOT NULL COMMENT '相关内容',
PRIMARY KEY (`aid`)
) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
2 changes: 1 addition & 1 deletion orm/_rawsqlfile/cms_Logininfo.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ CREATE TABLE `logininfo` (
`addregion` varchar(70) COLLATE utf8mb4_general_ci NOT NULL COMMENT '登录地区',
`loginstate` varchar(10) COLLATE utf8mb4_general_ci NOT NULL COMMENT '登录状态',
PRIMARY KEY (`lgid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='登录记录'
) ENGINE=InnoDB AUTO_INCREMENT=122 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='登录记录'
2 changes: 1 addition & 1 deletion orm/_rawsqlfile/cms_Testa.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ CREATE TABLE `testa` (
`deleted` tinyint unsigned NOT NULL,
`deletetime` int unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=34 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
) ENGINE=InnoDB AUTO_INCREMENT=35 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
2 changes: 1 addition & 1 deletion orm/_rawsqlfile/cms_Topic.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ CREATE TABLE `topic` (
`topimg` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '头图',
`accesscode` int unsigned NOT NULL COMMENT '权限代码',
PRIMARY KEY (`topicid`)
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='栏目表'
) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='栏目表'
2 changes: 1 addition & 1 deletion 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, 26 Jan 2024 03:07:14 GMT
*本文件为自动生成 Tue, 12 Mar 2024 04:11:29 GMT
***/
#include <iostream>
#include <cstdio>
Expand Down
2 changes: 1 addition & 1 deletion orm/cms/include/departmentbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define ORM_CMS_DEPARTMENTBASEMATA_H
/*
*This file is auto create from cli
*本文件为自动生成 Fri, 26 Jan 2024 02:59:40 GMT
*本文件为自动生成 Tue, 12 Mar 2024 04:11:11 GMT
***/
#include <iostream>
#include <cstdio>
Expand Down
2 changes: 1 addition & 1 deletion orm/cms/include/logininfobase.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define ORM_CMS_LOGININFOBASEMATA_H
/*
*This file is auto create from cli
*本文件为自动生成 Fri, 26 Jan 2024 02:59:40 GMT
*本文件为自动生成 Tue, 12 Mar 2024 04:11:11 GMT
***/
#include <iostream>
#include <cstdio>
Expand Down
2 changes: 1 addition & 1 deletion orm/cms/include/siteinfobase.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define ORM_CMS_SITEINFOBASEMATA_H
/*
*This file is auto create from cli
*本文件为自动生成 Fri, 26 Jan 2024 02:59:40 GMT
*本文件为自动生成 Tue, 12 Mar 2024 04:11:11 GMT
***/
#include <iostream>
#include <cstdio>
Expand Down
55 changes: 18 additions & 37 deletions orm/cms/include/testabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define ORM_CMS_TESTABASEMATA_H
/*
*This file is auto create from cli
*本文件为自动生成 Fri, 26 Jan 2024 02:59:40 GMT
*本文件为自动生成 Tue, 12 Mar 2024 04:11:11 GMT
***/
#include <iostream>
#include <cstdio>
Expand Down Expand Up @@ -1917,7 +1917,7 @@ if(tree_data[n].deletetime==0){
std::vector<meta_tree> to_tree(unsigned int beginid=0)
{
std::vector<meta_tree> temp;

unsigned int level=0;
if(beginid==0)
{
for (unsigned int i = 0; i < record.size(); i++)
Expand Down Expand Up @@ -1960,56 +1960,37 @@ if(tree_data[n].deletetime==0){
{
return temp;
}
for (unsigned int i = 0; i < record.size(); i++)
{
if (record[i].parentid > 0)
{
for (unsigned int j = 0; j < temp.size(); j++)
{
if (temp[j].id == record[i].parentid)
{
meta_tree temp_obja;
temp_obja.id=record[i].id;
temp_obja.parentid=record[i].parentid;
temp_obja.value_id=record[i].value_id;
temp_obja.content=record[i].content;
temp_obja.deleted=record[i].deleted;
temp_obja.deletetime=record[i].deletetime;

temp[j].children.push_back(temp_obja);
record_to_tree(temp[j].children);
}
}
}
}
level+=1;
for (unsigned int j = 0; j < temp.size(); j++)
{
record_to_tree(temp[j].children,temp[j].id,level);
}
return temp;
}
void record_to_tree(std::vector<meta_tree> &targetdata)
void record_to_tree(std::vector<meta_tree> &targetdata,long long t_vid,unsigned int level=0)
{
for (unsigned int i = 0; i < record.size(); i++)
{
if (record[i].parentid> 0)
if (record[i].parentid== t_vid)
{
for (unsigned int j = 0; j < targetdata.size(); j++)
{
if (targetdata[j].id == record[i].parentid)
{
meta_tree temp_obja;
meta_tree temp_obja;
temp_obja.id=record[i].id;
temp_obja.parentid=record[i].parentid;
temp_obja.value_id=record[i].value_id;
temp_obja.content=record[i].content;
temp_obja.deleted=record[i].deleted;
temp_obja.deletetime=record[i].deletetime;

targetdata[j].children.push_back(temp_obja);
record_to_tree(targetdata[j].children);
}
}
targetdata.push_back(temp_obja);
}
}
level+=1;
for (unsigned int j = 0; j < targetdata.size(); j++)
{
record_to_tree(targetdata[j].children,targetdata[j].id,level);
}
}
void tree_torecord(const std::vector<meta_tree> &sourcedata)
void tree_torecord(const std::vector<meta_tree> &sourcedata,unsigned int level=0)
{
for (unsigned int i = 0; i < sourcedata.size(); i++)
{
Expand All @@ -2024,7 +2005,7 @@ if(tree_data[n].deletetime==0){
record.push_back(temp_obja);
if(sourcedata[i].children.size()>0)
{
tree_torecord(sourcedata[i].children);
tree_torecord(sourcedata[i].children,level+1);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion orm/cms/include/testbbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define ORM_CMS_TESTBBASEMATA_H
/*
*This file is auto create from cli
*本文件为自动生成 Fri, 26 Jan 2024 02:59:40 GMT
*本文件为自动生成 Tue, 12 Mar 2024 04:11:11 GMT
***/
#include <iostream>
#include <cstdio>
Expand Down
2 changes: 1 addition & 1 deletion orm/cms/include/topicbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define ORM_CMS_TOPICBASEMATA_H
/*
*This file is auto create from cli
*本文件为自动生成 Fri, 26 Jan 2024 02:59:40 GMT
*本文件为自动生成 Tue, 12 Mar 2024 04:11:11 GMT
***/
#include <iostream>
#include <cstdio>
Expand Down
2 changes: 1 addition & 1 deletion 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, 26 Jan 2024 02:59:40 GMT
*本文件为自动生成 Tue, 12 Mar 2024 04:11:11 GMT
***/
#include <iostream>
#include <cstdio>
Expand Down
91 changes: 40 additions & 51 deletions vendor/httpcli/modelfun.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4855,20 +4855,29 @@ struct )";
std::string itemmember_str, tree_torecord_str;
itemmember_str.append("\t\tmeta_tree temp_obja;\n");
tree_torecord_str.append("\n\t\tmeta temp_obja;\n");
unsigned int j=0;
for (auto &fe : tablecollist)
{
if(fe=="level"&&colltypeshuzi[j] < 30)
{
itemmember_str.append("\t\t\t\t\t\ttemp_obja.level=level;\n");
tree_torecord_str.append("\t\t\ttemp_obja.level=level;\n");
}
else
{
itemmember_str.append("\t\t\t\t\t\ttemp_obja.");
itemmember_str.append(fe);
itemmember_str.append("=record[i].");
itemmember_str.append(fe);
itemmember_str.append(";\n");

itemmember_str.append("\t\t\t\t\t\ttemp_obja.");
itemmember_str.append(fe);
itemmember_str.append("=record[i].");
itemmember_str.append(fe);
itemmember_str.append(";\n");

tree_torecord_str.append("\t\t\ttemp_obja.");
tree_torecord_str.append(fe);
tree_torecord_str.append("=sourcedata[i].");
tree_torecord_str.append(fe);
tree_torecord_str.append(";\n");
tree_torecord_str.append("\t\t\ttemp_obja.");
tree_torecord_str.append(fe);
tree_torecord_str.append("=sourcedata[i].");
tree_torecord_str.append(fe);
tree_torecord_str.append(";\n");
}
j++;
}

headtxt = R"(
Expand Down Expand Up @@ -4928,7 +4937,7 @@ struct )";
std::vector<meta_tree> to_tree(unsigned int beginid=0)
{
std::vector<meta_tree> temp;

unsigned int level=0;
if(beginid==0)
{
for (unsigned int i = 0; i < record.size(); i++)
Expand Down Expand Up @@ -4965,58 +4974,38 @@ struct )";
{
return temp;
}
for (unsigned int i = 0; i < record.size(); i++)
{
if (record[i].)";
headtxt.append(parentitemname);
headtxt += R"( > 0)
{
for (unsigned int j = 0; j < temp.size(); j++)
{
if (temp[j].)";
level+=1;
for (unsigned int j = 0; j < temp.size(); j++)
{
record_to_tree(temp[j].children,temp[j].)";
headtxt.append(sourceidname);
headtxt += R"( == record[i].)";
headtxt.append(parentitemname);
headtxt += R"()
{
)";
headtxt.append(itemmember_str);
headtxt += R"(
temp[j].children.push_back(temp_obja);
record_to_tree(temp[j].children);
}
}
}
}
headtxt += R"(,level);
}
return temp;
}
void record_to_tree(std::vector<meta_tree> &targetdata)
void record_to_tree(std::vector<meta_tree> &targetdata,long long t_vid,unsigned int level=0)
{
for (unsigned int i = 0; i < record.size(); i++)
{
if (record[i].)";
headtxt.append(parentitemname);
headtxt += R"(> 0)
headtxt += R"(== t_vid)
{
for (unsigned int j = 0; j < targetdata.size(); j++)
{
if (targetdata[j].)";
headtxt.append(sourceidname);
headtxt += R"( == record[i].)";
headtxt.append(parentitemname);
headtxt += R"()
{
)";
)";
headtxt.append(itemmember_str);
headtxt += R"(
targetdata[j].children.push_back(temp_obja);
record_to_tree(targetdata[j].children);
}
}
targetdata.push_back(temp_obja);
}
}
level+=1;
for (unsigned int j = 0; j < targetdata.size(); j++)
{
record_to_tree(targetdata[j].children,targetdata[j].)";
headtxt.append(sourceidname);
headtxt += R"(,level);
}
}
void tree_torecord(const std::vector<meta_tree> &sourcedata)
void tree_torecord(const std::vector<meta_tree> &sourcedata,unsigned int level=0)
{
for (unsigned int i = 0; i < sourcedata.size(); i++)
{)";
Expand All @@ -5025,7 +5014,7 @@ struct )";
record.push_back(temp_obja);
if(sourcedata[i].children.size()>0)
{
tree_torecord(sourcedata[i].children);
tree_torecord(sourcedata[i].children,level+1);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions vendor/httpserver/src/datetime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ unsigned int strgmttotime(const std::string &gmtstr)
default: timeInfo.tm_mon = 0;
}
i += 4;
if ((i + 13) > gmtstr.length())
if ((unsigned int)(i + 13) > gmtstr.length())
{
return temp;
}
Expand Down Expand Up @@ -324,7 +324,7 @@ unsigned int strtotime(const std::string &str)
}
}

if ((i + 5) > str.length())
if ((unsigned int)(i + 5) > str.length())
{
return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions vendor/httpserver/src/request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1734,7 +1734,7 @@ std::string OBJ_VALUE::to_json()
}

break;
case NIL: os << "null"; break;
case NIL: os << "{}"; break;

case STRING: os << '"' << JSON_UTF8_TO_ASCII(string_v) << '"'; break;

Expand Down Expand Up @@ -2448,7 +2448,7 @@ std::ostream &operator<<(std::ostream &os, const http::OBJ_VALUE &v)
}

break;
case http::NIL: os << "null"; break;
case http::NIL: os << "{}"; break;

case http::STRING: os << '"' << http::JSON_UTF8_TO_ASCII(v.as_string()) << '"'; break;

Expand Down
2 changes: 1 addition & 1 deletion viewsrc/include/regviewmethod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace http
{
void _initview_method_regto(VIEW_REG &_viewmetholdreg)
{
//create time: Fri, 05 Jan 2024 04:56:12 GMT
//create time: Tue, 12 Mar 2024 03:55:33 GMT

_viewmetholdreg.emplace("admin/addarticle",http::view::admin::addarticle);
_viewmetholdreg.emplace("admin/addtopic",http::view::admin::addtopic);
Expand Down

0 comments on commit c8cf90b

Please sign in to comment.