树状结构优化

This commit is contained in:
hoteas
2022-08-25 13:02:44 +08:00
parent c959402250
commit 72d68d1738
3 changed files with 76 additions and 49 deletions
+4 -4
View File
@@ -368,7 +368,7 @@ var TptProject = Proj{
return
}
parent_ids := parentIndex.GetString("parent_ids") + that.RouterString[2] + ","
childNodes := that.Db.Select(tableName, "id,`parent_ids``", Map{"parent_ids[~]": "," + that.RouterString[2] + ","})
childNodes := that.Db.Select(tableName, "id,`parent_ids`", Map{"parent_ids[~]": "," + that.RouterString[2] + ","})
for _, v := range childNodes {
v["parent_ids"] = strings.Replace(v.GetString("parent_ids"), Index.GetString("parent_ids"), parent_ids, -1)
that.Db.Update(tableName, Map{"parent_ids": v["parent_ids"]}, Map{"id": v.GetCeilInt("id")})
@@ -395,11 +395,11 @@ var TptProject = Proj{
re := int64(0)
//有索引则删除对应的参数
if that.MakeCodeRouter[hotimeName].TableColumns[tableName]["parent_id"] != nil {
that.Db.Delete(tableName, Map{"parent_ids[~]": "," + that.RouterString[2] + ","})
re = that.Db.Delete(tableName, Map{"parent_ids[~]": "," + that.RouterString[2] + ","})
} else {
re = that.Db.Delete(tableName, Map{"id": that.RouterString[2]})
}
re = that.Db.Delete(tableName, Map{"id": that.RouterString[2]})
if re == 0 {
that.Display(4, "删除数据失败")
return