技术性调整

This commit is contained in:
hoteas
2022-07-25 05:37:19 +08:00
parent a1250e15c5
commit abc7eaf529
5 changed files with 104 additions and 58 deletions
+13 -13
View File
@@ -150,13 +150,13 @@ var TptProject = Proj{
return
}
//索引管理,便于检索以及权限
if inData.Get("parent_id") != nil && inData.GetString("index") != "" {
if inData.Get("parent_id") != nil && inData.GetString("parent_ids") != "" {
index := that.Db.Get(tableName, "`index`", Map{"id": inData.Get("parent_id")})
inData["index"] = index.GetString("index") + ObjToStr(re) + ","
that.Db.Update(tableName, Map{"index": inData["index"]}, Map{"id": re})
} else if inData.GetString("index") != "" {
inData["index"] = "," + ObjToStr(re) + ","
that.Db.Update(tableName, Map{"index": inData["index"]}, Map{"id": re})
inData["parent_ids"] = index.GetString("parent_ids") + ObjToStr(re) + ","
that.Db.Update(tableName, Map{"parent_ids": inData["parent_ids"]}, Map{"id": re})
} else if inData.GetString("parent_ids") != "" {
inData["parent_ids"] = "," + ObjToStr(re) + ","
that.Db.Update(tableName, Map{"parent_ids": inData["parent_ids"]}, Map{"id": re})
}
that.Log["table_id"] = re
that.Display(0, re)
@@ -263,20 +263,20 @@ var TptProject = Proj{
}
//索引管理,便于检索以及权限
if inData.GetString("index") != "" {
if inData.GetString("parent_ids") != "" {
if inData.Get("parent_id") != nil {
Index := that.Db.Get(tableName, "`index`", Map{"id": that.RouterString[2]})
parentIndex := that.Db.Get(tableName, "`index`", Map{"id": inData.Get("parent_id")})
inData["index"] = parentIndex.GetString("index") + that.RouterString[2] + ","
inData["parent_ids"] = parentIndex.GetString("parent_ids") + that.RouterString[2] + ","
childNodes := that.Db.Select(tableName, "id,`index``", Map{"index[~]": "," + that.RouterString[2] + ","})
for _, v := range childNodes {
v["index"] = strings.Replace(v.GetString("index"), Index.GetString("index"), inData.GetString("index"), -1)
that.Db.Update(tableName, Map{"index": v["index"]}, Map{"id": v.GetCeilInt("id")})
v["parent_ids"] = strings.Replace(v.GetString("parent_ids"), Index.GetString("parent_ids"), inData.GetString("parent_ids"), -1)
that.Db.Update(tableName, Map{"parent_ids": v["parent_ids"]}, Map{"id": v.GetCeilInt("id")})
}
} else {
delete(inData, "index")
delete(inData, "parent_ids")
}
}
@@ -301,7 +301,7 @@ var TptProject = Proj{
}
re := int64(0)
//索引管理,便于检索以及权限
if inData.Get("parent_id") != nil && inData.GetSlice("index") != nil {
if inData.Get("parent_id") != nil && inData.GetSlice("parent_ids") != nil {
re = that.Db.Delete(tableName, Map{"index[~]": "," + that.RouterString[2] + ","})
} else {
re = that.Db.Delete(tableName, Map{"id": that.RouterString[2]})
@@ -531,7 +531,7 @@ var TptProject = Proj{
where := Map{"name": name}
if that.MakeCodeRouter[hotimeName].TableColumns[fileConfig.GetString("table")]["phone"] != nil {
where["phone"] = name
where = Map{"AND": Map{"OR": where}, "password": Md5(password)}
where = Map{"AND": Map{"OR": where, "password": Md5(password)}}
} else {
where["password"] = Md5(password)
}