优化性能

This commit is contained in:
hoteas 2022-11-04 02:12:07 +08:00
parent 541c82410e
commit 203e72f8a2
6 changed files with 3501 additions and 5300 deletions

34
code.go
View File

@ -490,7 +490,7 @@ var TptProject = Proj{
} }
//} //}
columnStr, leftJoin, where := that.MakeCodeRouter[hotimeName].Search(tableName, data, where, that.Req, that.Db) columnStr, where := that.MakeCodeRouter[hotimeName].Search(tableName, data, where, that.Req, that.Db)
page := ObjToInt(that.Req.FormValue("page")) page := ObjToInt(that.Req.FormValue("page"))
pageSize := ObjToInt(that.Req.FormValue("pageSize")) pageSize := ObjToInt(that.Req.FormValue("pageSize"))
@ -509,12 +509,12 @@ var TptProject = Proj{
var reData []Map var reData []Map
//是否下载 //是否下载
if download == 0 { if download == 0 {
count = that.Db.Count(tableName, leftJoin, where) count = that.Db.Count(tableName, where)
reData = that.Db.Page(page, pageSize). reData = that.Db.Page(page, pageSize).
PageSelect(tableName, leftJoin, columnStr, where) PageSelect(tableName, columnStr, where)
} }
if download == 1 { if download == 1 {
reData = that.Db.Select(tableName, leftJoin, columnStr, where) reData = that.Db.Select(tableName, columnStr, where)
} }
for _, v := range reData { for _, v := range reData {
@ -547,7 +547,7 @@ var TptProject = Proj{
column := that.MakeCodeRouter[hotimeName].TableColumns[tableName][k] column := that.MakeCodeRouter[hotimeName].TableColumns[tableName][k]
if column == nil { if column == nil {
break continue
} }
if (column["list"] == nil || column["list"] == true) && column["name"] == "parent_id" && column.GetString("link") != "" { if (column["list"] == nil || column["list"] == true) && column["name"] == "parent_id" && column.GetString("link") != "" {
@ -559,6 +559,30 @@ var TptProject = Proj{
} }
} }
if column.GetString("link") != "" &&
column.GetString("name") != "parent_id" {
reStr := ""
if column.GetString("value") == "name" && that.MakeCodeRouter[hotimeName].TableColumns[column.GetString("link")]["nickname"] != nil {
reStr += "nickname,"
}
if that.MakeCodeRouter[hotimeName].TableColumns[column.GetString("link")]["phone"] != nil {
reStr += "phone,"
}
reStr += column.GetString("value")
joinData := that.Db.Get(column.GetString("link"), reStr, Map{"id": v.GetCeilInt(column.GetString("name"))})
if joinData != nil {
for kj, vj := range joinData {
v[column.GetString("link")+"_"+column.GetString("name")+"_"+kj] = vj
}
}
}
//return isEnd //return isEnd
} }
} }

View File

@ -847,9 +847,9 @@ func (that *MakeCode) Delete(table string, req *http.Request) Map {
return data return data
} }
func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Request, db *db.HoTimeDB) (string, Map, Map) { func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Request, db *db.HoTimeDB) (string, Map) {
reStr := "" reStr := ""
leftJoin := Map{} //leftJoin := Map{}
//data := Map{} //data := Map{}
if data == nil { if data == nil {
data = Map{} data = Map{}
@ -881,46 +881,48 @@ func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Req
if v["list"] != false { if v["list"] != false {
if v.GetString("link") != "" && //if v.GetString("link") != "" &&
v.GetString("name") != "parent_id" { // v.GetString("name") != "parent_id" {
//
reStr += table + "." + v.GetString("name") + "," + // reStr += table + "." + v.GetString("name") + ","
v.GetString("link") + "." + v.GetString("value") + " AS " + // //+
v.GetString("link") + "_" + v.GetString("name") + "_" + v.GetString("value") + "," // // v.GetString("link") + "." + v.GetString("value") + " AS " +
// // v.GetString("link") + "_" + v.GetString("name") + "_" + v.GetString("value") + ","
if v.GetString("value") == "name" && that.TableColumns[v.GetString("link")]["nickname"] != nil { //
reStr += v.GetString("link") + ".nickname AS " + // if v.GetString("value") == "name" && that.TableColumns[v.GetString("link")]["nickname"] != nil {
v.GetString("link") + "_" + v.GetString("name") + "_nickname," // reStr += v.GetString("link") + ".nickname AS " +
} // v.GetString("link") + "_" + v.GetString("name") + "_nickname,"
// }
if that.TableColumns[v.GetString("link")]["phone"] != nil { //
reStr += v.GetString("link") + ".phone AS " + // if that.TableColumns[v.GetString("link")]["phone"] != nil {
v.GetString("link") + "_" + v.GetString("name") + "_phone," // reStr += v.GetString("link") + ".phone AS " +
} // v.GetString("link") + "_" + v.GetString("name") + "_phone,"
// }
leftJoin["[>]"+v.GetString("link")] = //
table + "." + v.GetString("name") + "=" + // leftJoin["[>]"+v.GetString("link")] =
v.GetString("link") + ".id" // table + "." + v.GetString("name") + "=" +
if v.GetString("link") == "admin" { // v.GetString("link") + ".id"
hasUser = true //
} // if v.GetString("link") == "admin" {
// hasUser = true
reqValue := req.FormValue(v.GetString("name")) // }
if reqValue != "" { //
data[table+"."+v.GetString("name")] = reqValue // reqValue := req.FormValue(v.GetString("name"))
} // if reqValue != "" {
// data[table+"."+v.GetString("name")] = reqValue
} else { // }
//
//} else {
reStr += table + "." + v.GetString("name") + "," reStr += table + "." + v.GetString("name") + ","
} //}
if v["name"] == "parent_id" && v.GetString("link") != "" { //if v["name"] == "parent_id" && v.GetString("link") != "" {
leftJoin["[>]"+v.GetString("link")+" selfParent"] = // leftJoin["[>]"+v.GetString("link")+" selfParent"] =
"selfParent.id=" + // "selfParent.id=" +
v.GetString("link") + "." + v.GetString("name") // v.GetString("link") + "." + v.GetString("name")
reStr += "selfParent." + v.GetString("value") + " AS " + v.GetString("link") + "_" + v.GetString("name") + "_" + v.GetString("value") + "," // reStr += "selfParent." + v.GetString("value") + " AS " + v.GetString("link") + "_" + v.GetString("name") + "_" + v.GetString("value") + ","
} //}
//准备加入索引权限 //准备加入索引权限
if v.GetString("link") != "" && if v.GetString("link") != "" &&
@ -1273,5 +1275,5 @@ func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Req
} }
} }
return reStr, leftJoin, where return reStr, where
} }

View File

@ -1029,7 +1029,7 @@ func (that *HoTimeDB) varCond(k string, v interface{}) (string, []interface{}) {
v = "%" + ObjToStr(v) + "%" v = "%" + ObjToStr(v) + "%"
res = append(res, v) res = append(res, v)
case "[!~]": //左边任意 case "[!~]": //左边任意
k = strings.Replace(k, "[~]", "", -1) k = strings.Replace(k, "[!~]", "", -1)
if !strings.Contains(k, ".") { if !strings.Contains(k, ".") {
k = "`" + k + "` " k = "`" + k + "` "
} }
@ -1037,7 +1037,7 @@ func (that *HoTimeDB) varCond(k string, v interface{}) (string, []interface{}) {
v = "%" + ObjToStr(v) + "" v = "%" + ObjToStr(v) + ""
res = append(res, v) res = append(res, v)
case "[~!]": //右边任意 case "[~!]": //右边任意
k = strings.Replace(k, "[~]", "", -1) k = strings.Replace(k, "[~!]", "", -1)
if !strings.Contains(k, ".") { if !strings.Contains(k, ".") {
k = "`" + k + "` " k = "`" + k + "` "
} }

View File

@ -1,419 +0,0 @@
{
"flow": {
"admin": {
"sql": {
"org_id": "org_id",
"parent_ids[~]": "%,id,%",
"role_id": "role_id",
"zone_id": "zone_id"
},
"stop": true,
"table": "admin"
},
"channel": {
"sql": {
"admin_id": "id",
"org_id": "org_id",
"zone_id": "zone_id"
},
"stop": false,
"table": "channel"
},
"company": {
"sql": {
"admin_id": "id",
"org_id": "org_id",
"zone_id": "zone_id"
},
"stop": false,
"table": "company"
},
"logs": {
"sql": {
"admin_id": "id"
},
"stop": false,
"table": "logs"
},
"org": {
"sql": {
"admin_id": "id",
"parent_ids[~]": "%,org_id,%",
"zone_id": "zone_id"
},
"stop": true,
"table": "org"
},
"proj": {
"sql": {
"admin_id": "id",
"org_id": "org_id",
"sc_admin_id": "sc_admin_id",
"xm_admin_id": "xm_admin_id",
"zone_id": "zone_id"
},
"stop": false,
"table": "proj"
},
"role": {
"sql": {
"id": "role_id"
},
"stop": true,
"table": "role"
},
"sea": {
"sql": {
"admin_id": "id"
},
"stop": false,
"table": "sea"
},
"task": {
"sql": {
"admin_id": "id",
"zone_id": "zone_id"
},
"stop": false,
"table": "task"
},
"task_admin": {
"sql": {
"admin_id": "id",
"zone_id": "zone_id"
},
"stop": false,
"table": "task_admin"
},
"user": {
"sql": {
"admin_id": "id",
"zone_id": "zone_id"
},
"stop": false,
"table": "user"
},
"wechat": {
"sql": {
"admin_id": "id",
"org_id": "org_id"
},
"stop": false,
"table": "wechat"
},
"zone": {
"sql": {
"parent_ids[~]": "%,zone_id,%"
},
"stop": true,
"table": "zone"
}
},
"id": "023d5002b1e2c64ed744a12ac442c00e",
"label": "HoTime管理平台",
"labelConfig": {
"add": "添加",
"delete": "删除",
"download": "下载清单",
"edit": "编辑",
"info": "查看详情",
"show": "开启"
},
"menus": [
{
"auth": [
"show"
],
"icon": "Setting",
"label": "系统管理",
"menus": [
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "角色管理",
"table": "role"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "联络人管理",
"table": "user"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "项目分类",
"table": "category"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "标签管理",
"table": "out_tag"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "考勤管理",
"table": "time_tag"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "车辆管理",
"table": "car"
},
{
"auth": [
"show",
"download"
],
"label": "日志管理",
"table": "logs"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "系统设置",
"table": "system"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "标签管理",
"table": "visit_tag"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "城市管理",
"table": "city"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "项目管理",
"table": "proj"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "客户管理",
"table": "company"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "项目归口",
"table": "department"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "部门管理",
"table": "org"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "用章管理",
"table": "seal_tag"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "微信信息",
"table": "wechat"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "联盟公司",
"table": "zone"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "人员管理",
"table": "admin"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "供应商管理",
"table": "channel"
}
],
"name": "sys"
},
{
"auth": [
"show"
],
"icon": "Setting",
"label": "任务执行",
"menus": [
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "任务执行",
"table": "task_admin"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "任务管理",
"table": "task"
}
],
"name": "sys:task"
},
{
"auth": [
"show"
],
"icon": "Setting",
"label": "跟进管理",
"menus": [
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "跟进管理",
"table": "sea"
}
],
"name": "sys:sea"
}
],
"name": "admin",
"stop": [
"role",
"org"
]
}

File diff suppressed because it is too large Load Diff

View File

@ -24,7 +24,7 @@
"db": { "db": {
"mysql": { "mysql": {
"host": "192.168.6.253", "host": "192.168.6.253",
"name": "rfcb", "name": "dgs-cms",
"password": "dasda8454456", "password": "dasda8454456",
"port": "3306", "port": "3306",
"user": "root" "user": "root"