From 9425544d1c02fda9149aecfb586eb11c6685f9b1 Mon Sep 17 00:00:00 2001 From: hoteas Date: Thu, 4 Aug 2022 02:41:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code.go | 695 +++++++++++------------------------- code/config.go | 1 + code/makecode.go | 44 +-- example/config/config.json | 8 +- example/config/config1.json | 49 --- 5 files changed, 214 insertions(+), 583 deletions(-) delete mode 100644 example/config/config1.json diff --git a/code.go b/code.go index 625adef..aa71726 100644 --- a/code.go +++ b/code.go @@ -57,45 +57,6 @@ var TptProject = Proj{ } re[link] = that.Db.Get(column.GetString("link"), seStr, Map{"id": v}) } - - //权限设置 - if column["type"] == "auth" { - - btes, err := ioutil.ReadFile(fileConfig.GetString("config")) - - if err != nil { - that.Display(4, "找不到权限配置文件") - return - } - - conf := ObjToMap(string(btes)) - menus := conf.GetSlice("menus") - - userAuth := re.GetMap("auth") - - for k1, _ := range menus { - v1 := menus.GetMap(k1) - if userAuth[v1.GetString("name")] != nil { - v1["auth"] = userAuth[v1.GetString("name")] - } - if userAuth[v1.GetString("table")] != nil { - v1["auth"] = userAuth[v1.GetString("table")] - } - v1menus := v1.GetSlice("menus") - for k2, _ := range v1menus { - v2 := v1menus.GetMap(k2) - if userAuth[v2.GetString("name")] != nil { - v2["auth"] = userAuth[v2.GetString("name")] - } - if userAuth[v2.GetString("table")] != nil { - v2["auth"] = userAuth[v2.GetString("table")] - } - } - } - re["auth"] = menus.ToJsonString() - //that.Display(0,menus) - } - } //如果有table字段则代为link @@ -137,7 +98,7 @@ var TptProject = Proj{ if v.GetString("link") != "" { if v.GetString("link") == tableName && that.MakeCodeRouter[hotimeName].TableColumns[v.GetString("link")]["parent_id"] != nil { - if inData["parent_id"] == nil { + if inData["parent_id"] == nil && data[v.GetString("name")] != nil { inData["parent_id"] = data.GetCeilInt64(v.GetString("name")) pre := that.Db.Get(v.GetString("link"), "parent_ids", Map{"id": data.GetCeilInt64(v.GetString("name"))}) inData["parent_ids"] = pre.GetString("parent_ids") @@ -145,220 +106,89 @@ var TptProject = Proj{ } } - } - if inData["auth"] != nil { + if v.GetString("link") == tableName && that.MakeCodeRouter[hotimeName].TableColumns[v.GetString("link")]["auth"] != nil { + linkAuthMap := that.Db.Get(v.GetString("link"), "auth", Map{"id": data.GetCeilInt(v.GetString("name"))}) + linkAuth := linkAuthMap.GetMap("auth") - btes, err := ioutil.ReadFile(fileConfig.GetString("config")) - - if err != nil { - that.Display(4, "找不到配置文件") - return - } - - conf := ObjToMap(string(btes)) - menus := conf.GetSlice("menus") - - for _, v := range that.MakeCodeRouter[hotimeName].TableColumns[fileConfig.GetString("table")] { - if v.GetString("link") != "" && that.MakeCodeRouter[hotimeName].TableColumns[v.GetString("link")]["auth"] != nil { - //linkHasAuth := that.MakeCodeRouter[hotimeName].TableColumns[v.GetString("link")]["auth"] - //if linkHasAuth != nil { - - linkAuthMap := that.Db.Get(v.GetString("link"), "auth", Map{"id": data.GetCeilInt(v.GetString("name"))}) - linkAuth := linkAuthMap.GetMap("auth") - myAuth := Map{} - if linkAuth != nil { - - for k1, _ := range menus { - - v1 := menus.GetMap(k1) - - if linkAuth[v1.GetString("table")] != nil { - v1["auth"] = linkAuth[v1.GetString("table")] - - } - if linkAuth[v1.GetString("name")] != nil { - v1["auth"] = linkAuth[v1.GetString("name")] - - } - - if v1.GetString("name") != "" && v1["auth"] == nil { - v1["auth"] = Slice{"show"} - - } - - if v1.GetString("table") != "" && v1["auth"] == nil { - v1["auth"] = that.MakeCodeRouter[hotimeName].TableConfig.GetMap(v1.GetString("table"))["auth"] - } - - if v1.GetString("table") != "" { - myAuth[v1.GetString("table")] = v1 - } - if v1.GetString("name") != "" { - myAuth[v1.GetString("name")] = v1 - } - - v1menus := v1.GetSlice("menus") - for k2, _ := range v1menus { - v2 := v1menus.GetMap(k2) - if linkAuth[v2.GetString("table")] != nil { - v2["auth"] = linkAuth[v2.GetString("table")] - - } - - if linkAuth[v2.GetString("name")] != nil { - v2["auth"] = linkAuth[v2.GetString("name")] - } - - if v2.GetString("name") != "" && v2["auth"] == nil { - v2["auth"] = Slice{"show"} - - } - - if v2.GetString("table") != "" && v2["auth"] == nil { - v2["auth"] = that.MakeCodeRouter[hotimeName].TableConfig.GetMap(v2.GetString("table"))["auth"] - } - - if v2.GetString("table") != "" { - myAuth[v2.GetString("table")] = v2 - } - - if v2.GetString("name") != "" { - myAuth[v2.GetString("name")] = v2 - } - } - } + if linkAuth == nil { + btes, err := ioutil.ReadFile(fileConfig.GetString("config")) + if err != nil { + that.Display(4, "找不到配置文件") + return } + linkAuth = Map{} + conf := ObjToMap(string(btes)) + menus := conf.GetSlice("menus") - newAuth := inData.GetSlice("auth") - toDB := Map{} - for k1, _ := range newAuth { - v1 := newAuth.GetMap(k1) - - if myAuth.GetMap(v1.GetString("name")) == nil && myAuth.GetMap(v1.GetString("table")) == nil { - continue + for k1, _ := range menus { + v1 := menus.GetMap(k1) + name := v1.GetString("name") + if name == "" { + name = v1.GetString("table") } + if v1["auth"] != nil { + linkAuth[name] = v1["auth"] - auth := Slice{} - - str := v1.GetString("name") - - if v1.GetString("table") != "" { - - str = v1.GetString("table") } - - if v1.GetString("auth") == "" { - if myAuth.GetMap(str).GetString("table") != "" { - auth = that.MakeCodeRouter[hotimeName].TableConfig.GetMap(str).GetSlice("auth") + if v1["auth"] == nil { + table := that.MakeCodeRouter[hotimeName].TableConfig.GetMap(name) + if table != nil { + linkAuth[name] = that.MakeCodeRouter[hotimeName].TableConfig.GetMap(name)["auth"] } else { - auth = Slice{"show"} + linkAuth[name] = Slice{"show"} } - - } else { - - if strings.Contains(myAuth.GetMap(str).GetString("auth"), `"show"`) && - strings.Contains(v1.GetString("auth"), `"show"`) { - auth = append(auth, "show") - - } - - if strings.Contains(myAuth.GetMap(str).GetString("auth"), `"download"`) && - strings.Contains(v1.GetString("auth"), `"download"`) { - auth = append(auth, "download") - - } - - if strings.Contains(myAuth.GetMap(str).GetString("auth"), `"add"`) && - strings.Contains(v1.GetString("auth"), `"add"`) { - auth = append(auth, "add") - //continue - } - if strings.Contains(myAuth.GetMap(str).GetString("auth"), `"edit"`) && - strings.Contains(v1.GetString("auth"), `"edit"`) { - auth = append(auth, "edit") - - } - if strings.Contains(myAuth.GetMap(str).GetString("auth"), `"delete"`) && - strings.Contains(v1.GetString("auth"), `"delete"`) { - auth = append(auth, "delete") - - } - if strings.Contains(myAuth.GetMap(str).GetString("auth"), `"info"`) && - strings.Contains(v1.GetString("auth"), `"info"`) { - auth = append(auth, "info") - - } - } - toDB[str] = auth - v1Menus := v1.GetSlice("menus") - for k2, _ := range v1Menus { - v2 := v1Menus.GetMap(k2) - if myAuth.GetMap(v2.GetString("name")) == nil && myAuth.GetMap(v2.GetString("table")) == nil { + menusChild := v1.GetSlice("menus") + for k2, _ := range menusChild { + v2 := menusChild.GetMap(k2) + name := v2.GetString("name") + if name == "" { + name = v2.GetString("table") + } + if v2["auth"] != nil { + linkAuth[name] = v2["auth"] continue } - - auth := Slice{} - - str := v2.GetString("name") - - if v2.GetString("table") != "" { - - str = v2.GetString("table") - } - - if v2.GetString("auth") == "" { - if myAuth.GetMap(str).GetString("table") != "" { - auth = that.MakeCodeRouter[hotimeName].TableConfig.GetMap(str).GetSlice("auth") + if v2["auth"] == nil { + table := that.MakeCodeRouter[hotimeName].TableConfig.GetMap(name) + if table != nil { + linkAuth[name] = that.MakeCodeRouter[hotimeName].TableConfig.GetMap(name)["auth"] } else { - auth = Slice{"show"} + linkAuth[name] = Slice{"show"} } - - } else { - - if strings.Contains(myAuth.GetMap(str).GetString("auth"), `"show"`) && - strings.Contains(v2.GetString("auth"), `"show"`) { - auth = append(auth, "show") - - } - if strings.Contains(myAuth.GetMap(str).GetString("auth"), `"download"`) && - strings.Contains(v1.GetString("auth"), `"download"`) { - auth = append(auth, "download") - - } - if strings.Contains(myAuth.GetMap(str).GetString("auth"), `"add"`) && - strings.Contains(v2.GetString("auth"), `"add"`) { - auth = append(auth, "add") - //continue - } - if strings.Contains(myAuth.GetMap(str).GetString("auth"), `"edit"`) && - strings.Contains(v2.GetString("auth"), `"edit"`) { - auth = append(auth, "edit") - - } - if strings.Contains(myAuth.GetMap(str).GetString("auth"), `"delete"`) && - strings.Contains(v2.GetString("auth"), `"delete"`) { - auth = append(auth, "delete") - - } - if strings.Contains(myAuth.GetMap(str).GetString("auth"), `"info"`) && - strings.Contains(v2.GetString("auth"), `"info"`) { - auth = append(auth, "info") - - } - } - toDB[str] = auth - } - } - inData["auth"] = toDB.ToJsonString() - break } - //} + + toDB := Map{} + newAuth := inData.GetMap("auth") + if newAuth == nil { + inData["auth"] = linkAuth.ToJsonString() + continue + } + + for k1, _ := range newAuth { + v1 := newAuth.GetSlice(k1) + if linkAuth.GetString(k1) == "" { + continue + } + toDbli := Slice{} + for k2, _ := range v1 { + v2 := v1.GetString(k2) + + if !strings.Contains(linkAuth.GetString(k1), `"`+v2+`"`) { + continue + } + toDbli = append(toDbli, v2) + } + toDB[k1] = toDbli + } + + inData["auth"] = toDB.ToJsonString() + //break } } @@ -393,237 +223,114 @@ var TptProject = Proj{ that.Display(3, "没有找到要更新的数据") return } + data := that.Db.Get(fileConfig.GetString("table"), "*", Map{"id": that.Session(fileConfig.GetString("table") + "_id").ToCeilInt()}) //树状结构不允许修改自身的属性,修改别人的可以 - if fileConfig.GetString("table") == tableName && that.RouterString[2] == that.Session(fileConfig.GetString("table")+"_id").ToStr() { + btes, err := ioutil.ReadFile(fileConfig.GetString("config")) + if err != nil { + that.Display(4, "找不到权限配置文件") + return + } - for _, v := range that.MakeCodeRouter[hotimeName].TableColumns[fileConfig.GetString("table")] { - - if v.GetString("link") == "" { - continue - } - - if that.MakeCodeRouter[hotimeName].TableColumns[v.GetString("link")]["parent_id"] != nil { - - delete(inData, v.GetString("name")) - } + conf := ObjToMap(string(btes)) + stop := conf.GetSlice("stop") + for k, _ := range stop { + v := stop.GetString(k) + //不能改对应行数据 + if tableName == v && data.GetCeilInt64(v+"_id") == ObjToCeilInt64(that.RouterString[2]) { + that.Display(4, "你没有权限修改当前数据") + return + } + //不能改自身对应的数据 + if tableName == fileConfig.GetString("table") && inData[v+"_id"] != nil { + delete(inData, v+"_id") } } if inData["auth"] != nil { - - btes, err := ioutil.ReadFile(fileConfig.GetString("config")) - - if err != nil { - that.Display(4, "找不到配置文件") - return - } - - conf := ObjToMap(string(btes)) menus := conf.GetSlice("menus") - for _, v := range that.MakeCodeRouter[hotimeName].TableColumns[fileConfig.GetString("table")] { - if v.GetString("link") != "" && that.MakeCodeRouter[hotimeName].TableColumns[v.GetString("link")]["auth"] != nil { - //linkHasAuth := that.MakeCodeRouter[hotimeName].TableColumns[v.GetString("link")]["auth"] - //if linkHasAuth != nil { + if v.GetString("link") != "" && that.MakeCodeRouter[hotimeName].TableColumns[v.GetString("link")]["auth"] != nil { linkAuthMap := that.Db.Get(v.GetString("link"), "auth", Map{"id": data.GetCeilInt(v.GetString("name"))}) linkAuth := linkAuthMap.GetMap("auth") - myAuth := Map{} - if linkAuth != nil { + if linkAuth == nil { + + linkAuth = Map{} for k1, _ := range menus { - v1 := menus.GetMap(k1) - - if linkAuth[v1.GetString("table")] != nil { - v1["auth"] = linkAuth[v1.GetString("table")] - + name := v1.GetString("name") + if name == "" { + name = v1.GetString("table") } - if linkAuth[v1.GetString("name")] != nil { - v1["auth"] = linkAuth[v1.GetString("name")] - - } - - if v1.GetString("name") != "" && v1["auth"] == nil { - v1["auth"] = Slice{"show"} - - } - - if v1.GetString("table") != "" && v1["auth"] == nil { - v1["auth"] = that.MakeCodeRouter[hotimeName].TableConfig.GetMap(v1.GetString("table"))["auth"] - } - - if v1.GetString("table") != "" { - myAuth[v1.GetString("table")] = v1 - } - if v1.GetString("name") != "" { - myAuth[v1.GetString("name")] = v1 - } - - v1menus := v1.GetSlice("menus") - for k2, _ := range v1menus { - v2 := v1menus.GetMap(k2) - if linkAuth[v2.GetString("table")] != nil { - v2["auth"] = linkAuth[v2.GetString("table")] - - } - - if linkAuth[v2.GetString("name")] != nil { - v2["auth"] = linkAuth[v2.GetString("name")] - } - - if v2.GetString("name") != "" && v2["auth"] == nil { - v2["auth"] = Slice{"show"} - - } - - if v2.GetString("table") != "" && v2["auth"] == nil { - v2["auth"] = that.MakeCodeRouter[hotimeName].TableConfig.GetMap(v2.GetString("table"))["auth"] - } - - if v2.GetString("table") != "" { - myAuth[v2.GetString("table")] = v2 - } - - if v2.GetString("name") != "" { - myAuth[v2.GetString("name")] = v2 - } - } - } - } - - newAuth := inData.GetSlice("auth") - toDB := Map{} - for k1, _ := range newAuth { - v1 := newAuth.GetMap(k1) - - if myAuth.GetMap(v1.GetString("name")) == nil && myAuth.GetMap(v1.GetString("table")) == nil { - continue - } - - auth := Slice{} - - str := v1.GetString("name") - - if v1.GetString("table") != "" { - - str = v1.GetString("table") - } - - if v1.GetString("auth") == "" { - if myAuth.GetMap(str).GetString("table") != "" { - auth = that.MakeCodeRouter[hotimeName].TableConfig.GetMap(str).GetSlice("auth") - } else { - auth = Slice{"show"} - } - - } else { - - if strings.Contains(myAuth.GetMap(str).GetString("auth"), `"show"`) && - strings.Contains(v1.GetString("auth"), `"show"`) { - auth = append(auth, "show") - - } - if strings.Contains(myAuth.GetMap(str).GetString("auth"), `"download"`) && - strings.Contains(v1.GetString("auth"), `"download"`) { - auth = append(auth, "download") - - } - if strings.Contains(myAuth.GetMap(str).GetString("auth"), `"add"`) && - strings.Contains(v1.GetString("auth"), `"add"`) { - auth = append(auth, "add") - //continue - } - if strings.Contains(myAuth.GetMap(str).GetString("auth"), `"edit"`) && - strings.Contains(v1.GetString("auth"), `"edit"`) { - auth = append(auth, "edit") - - } - if strings.Contains(myAuth.GetMap(str).GetString("auth"), `"delete"`) && - strings.Contains(v1.GetString("auth"), `"delete"`) { - auth = append(auth, "delete") - - } - if strings.Contains(myAuth.GetMap(str).GetString("auth"), `"info"`) && - strings.Contains(v1.GetString("auth"), `"info"`) { - auth = append(auth, "info") - - } - - } - toDB[str] = auth - v1Menus := v1.GetSlice("menus") - for k2, _ := range v1Menus { - v2 := v1Menus.GetMap(k2) - - if myAuth.GetMap(v2.GetString("name")) == nil && myAuth.GetMap(v2.GetString("table")) == nil { + if v1["auth"] != nil { + linkAuth[name] = v1["auth"] continue } + if v1["auth"] == nil { - auth := Slice{} - - str := v2.GetString("name") - - if v2.GetString("table") != "" { - - str = v2.GetString("table") - } - - if v2.GetString("auth") == "" { - if myAuth.GetMap(str).GetString("table") != "" { - auth = that.MakeCodeRouter[hotimeName].TableConfig.GetMap(str).GetSlice("auth") + table := that.MakeCodeRouter[hotimeName].TableConfig.GetMap(name) + if table != nil { + linkAuth[name] = that.MakeCodeRouter[hotimeName].TableConfig.GetMap(name)["auth"] } else { - auth = Slice{"show"} + linkAuth[name] = Slice{"show"} + } + } + menusChild := v1.GetSlice("menus") + for k2, _ := range menusChild { + v2 := menusChild.GetMap(k2) + name := v2.GetString("name") + if name == "" { + name = v2.GetString("table") + } + if v2["auth"] != nil { + linkAuth[name] = v2["auth"] + continue + } + if v2["auth"] == nil { + table := that.MakeCodeRouter[hotimeName].TableConfig.GetMap(name) + if table != nil { + linkAuth[name] = that.MakeCodeRouter[hotimeName].TableConfig.GetMap(name)["auth"] + } else { + linkAuth[name] = Slice{"show"} + } } - - } else { - - if strings.Contains(myAuth.GetMap(str).GetString("auth"), `"show"`) && - strings.Contains(v2.GetString("auth"), `"show"`) { - auth = append(auth, "show") - - } - if strings.Contains(myAuth.GetMap(str).GetString("auth"), `"download"`) && - strings.Contains(v1.GetString("auth"), `"download"`) { - auth = append(auth, "download") - - } - if strings.Contains(myAuth.GetMap(str).GetString("auth"), `"add"`) && - strings.Contains(v2.GetString("auth"), `"add"`) { - auth = append(auth, "add") - //continue - } - if strings.Contains(myAuth.GetMap(str).GetString("auth"), `"edit"`) && - strings.Contains(v2.GetString("auth"), `"edit"`) { - auth = append(auth, "edit") - - } - if strings.Contains(myAuth.GetMap(str).GetString("auth"), `"delete"`) && - strings.Contains(v2.GetString("auth"), `"delete"`) { - auth = append(auth, "delete") - - } - if strings.Contains(myAuth.GetMap(str).GetString("auth"), `"info"`) && - strings.Contains(v2.GetString("auth"), `"info"`) { - auth = append(auth, "info") - - } - } - toDB[str] = auth - } - } + + toDB := Map{} + newAuth := inData.GetMap("auth") + if newAuth == nil || len(newAuth) == 0 { + inData["auth"] = linkAuth.ToJsonString() + break + } + //不可超出用户权限 + for k1, _ := range newAuth { + v1 := newAuth.GetSlice(k1) + if linkAuth.GetString(k1) == "" { + continue + } + toDbli := Slice{} + for k2, _ := range v1 { + v2 := v1.GetString(k2) + if !strings.Contains(linkAuth.GetString(k1), `"`+v2+`"`) { + continue + } + toDbli = append(toDbli, v2) + } + toDB[k1] = toDbli + } + inData["auth"] = toDB.ToJsonString() break } - //} } + } //索引管理,便于检索以及权限 @@ -931,47 +638,7 @@ var TptProject = Proj{ } re[link] = that.Db.Get(column.GetString("link"), seStr, Map{"id": v}) } - - //权限设置 - if column["type"] == "auth" { - - btes, err := ioutil.ReadFile(fileConfig.GetString("config")) - - if err != nil { - that.Display(4, "找不到权限配置文件") - return - } - - conf := ObjToMap(string(btes)) - menus := conf.GetSlice("menus") - - userAuth := re.GetMap("auth") - - for k1, _ := range menus { - v1 := menus.GetMap(k1) - if userAuth[v1.GetString("name")] != nil { - v1["auth"] = userAuth[v1.GetString("name")] - } - if userAuth[v1.GetString("table")] != nil { - v1["auth"] = userAuth[v1.GetString("table")] - } - v1menus := v1.GetSlice("menus") - for k2, _ := range v1menus { - v2 := v1menus.GetMap(k2) - if userAuth[v2.GetString("name")] != nil { - v2["auth"] = userAuth[v2.GetString("name")] - } - if userAuth[v2.GetString("table")] != nil { - v2["auth"] = userAuth[v2.GetString("table")] - } - } - } - re["auth"] = menus.ToJsonString() - //that.Display(0,menus) - } - } - //如果有table字段则代为link if re["table"] != nil && re["table_id"] != nil { @@ -1073,9 +740,60 @@ var TptProject = Proj{ linkAuthMap := that.Db.Get(v.GetString("link"), "auth", Map{"id": user.GetCeilInt(v.GetString("name"))}) linkAuth := linkAuthMap.GetMap("auth") + if linkAuth == nil { + linkAuth = Map{} + conf := ObjToMap(string(btes)) + menus := conf.GetSlice("menus") + + for k1, _ := range menus { + v1 := menus.GetMap(k1) + name := v1.GetString("name") + if name == "" { + name = v1.GetString("table") + } + if v1["auth"] != nil { + linkAuth[name] = v1["auth"] + continue + } + if v1["auth"] == nil { + + table := that.MakeCodeRouter[hotimeName].TableConfig.GetMap(name) + if table != nil { + linkAuth[name] = that.MakeCodeRouter[hotimeName].TableConfig.GetMap(name)["auth"] + } else { + linkAuth[name] = Slice{"show"} + } + } + menusChild := v1.GetSlice("menus") + for k2, _ := range menusChild { + v2 := menusChild.GetMap(k2) + name := v2.GetString("name") + if name == "" { + name = v2.GetString("table") + } + if v2["auth"] != nil { + linkAuth[name] = v2["auth"] + continue + } + if v2["auth"] == nil { + table := that.MakeCodeRouter[hotimeName].TableConfig.GetMap(name) + if table != nil { + linkAuth[name] = that.MakeCodeRouter[hotimeName].TableConfig.GetMap(name)["auth"] + } else { + linkAuth[name] = Slice{"show"} + } + } + } + } + } for k1, _ := range menus { v1 := menus.GetMap(k1) + //保证个人权限可用 + if fileConfig.GetString("table") == v1.GetString("table") { + v1["auth"] = Slice{"info", "edit"} + } + if linkAuth[v1.GetString("name")] != nil { v1["auth"] = linkAuth[v1.GetString("name")] } @@ -1085,6 +803,13 @@ var TptProject = Proj{ v1menus := v1.GetSlice("menus") for k2, _ := range v1menus { v2 := v1menus.GetMap(k2) + + //保证个人权限可用 + if fileConfig.GetString("table") == v2.GetString("table") { + v2["auth"] = Slice{"info", "edit"} + + } + if linkAuth[v2.GetString("name")] != nil { v2["auth"] = linkAuth[v2.GetString("name")] } @@ -1094,37 +819,27 @@ var TptProject = Proj{ } } + break } } - userAuth := user.GetMap("auth") - for k1, _ := range menus { - v1 := menus.GetMap(k1) - if userAuth[v1.GetString("table")] != nil { - v1["auth"] = userAuth[v1.GetString("table")] - } - v1menus := v1.GetSlice("menus") - for k2, _ := range v1menus { - v2 := v1menus.GetMap(k2) - if userAuth[v2.GetString("table")] != nil { - v2["auth"] = userAuth[v2.GetString("table")] - } - } - } //不可读写数据 config := DeepCopyMap(that.MakeCodeRouter[hotimeName].Config).(Map) config["menus"] = menus newTables := Map{} + newTables[fileConfig.GetString("table")] = config.GetMap("tables").GetMap(fileConfig.GetString("table")) for k1, _ := range menus { v1 := menus.GetMap(k1) if config.GetMap("tables").GetMap(v1.GetString("table")) != nil { + config.GetMap("tables").GetMap(v1.GetString("table"))["auth"] = Slice{} newTables[v1.GetString("name")] = config.GetMap("tables").GetMap(v1.GetString("table")) } v1menus := v1.GetSlice("menus") for k2, _ := range v1.GetSlice("menus") { v2 := v1menus.GetMap(k2) if config.GetMap("tables").GetMap(v2.GetString("table")) != nil { + //有自定义配置文件 if conf.GetMap("tables") != nil && conf.GetMap("tables").GetMap(v2.GetString("table")) != nil { @@ -1143,7 +858,7 @@ var TptProject = Proj{ } } - + config.GetMap("tables").GetMap(v2.GetString("table"))["auth"] = Slice{} newTables[v2.GetString("table")] = config.GetMap("tables").GetMap(v2.GetString("table")) } diff --git a/code/config.go b/code/config.go index d095095..3aebe7f 100644 --- a/code/config.go +++ b/code/config.go @@ -8,6 +8,7 @@ var Config = Map{ "name": "HoTimeDashBoard", //"id": "2f92h3herh23rh2y8", "label": "HoTime管理平台", + "stop": Slice{"role", "org"}, //不更新的,同时不允许修改用户自身对应的表数据 "labelConfig": Map{ "show": "开启", "add": "添加", diff --git a/code/makecode.go b/code/makecode.go index 7bd0e31..b61d9a1 100644 --- a/code/makecode.go +++ b/code/makecode.go @@ -84,38 +84,6 @@ func (that *MakeCode) Db2JSON(db *db.HoTimeDB, config Map) { } that.IndexMenus = Map{} - //menusConfig := that.Config.GetSlice("menus") - ////将配置写入到内存中仅作为判断用 - //if menusConfig != nil { - // for kmenu, _ := range menusConfig { - // menu := menusConfig.GetMap(kmenu) - // if menu != nil { - // mname := menu.GetString("table") - // if mname == "" { //如果为空则不是表格 - // mname = menu.GetString("name") - // } - // that.IndexMenus[mname] = menu - // childMenus := menu.GetSlice("menus") - // if childMenus != nil { - // for ckmenu, _ := range childMenus { - // cmenu := childMenus.GetMap(ckmenu) - // if cmenu != nil { - // cname := cmenu.GetString("table") - // if cmenu.GetString("table") == "" { - // continue - // } - // that.IndexMenus[mname+"/"+cname] = cmenu - // } - // - // } - // - // } - // - // } - // - // } - //} - that.TableConfig = that.Config.GetMap("tables") if that.TableConfig == nil { that.TableConfig = Map{} @@ -321,13 +289,6 @@ func (that *MakeCode) Db2JSON(db *db.HoTimeDB, config Map) { //} } - //else { - // - // //if !(coloum.GetString("label") != "备注" && info.GetString("label") == "备注") { - // // coloum["label"] = info.GetString("label") - // //} - // //coloum["type"] = info.GetString("type") - //} //暂时不关闭参数,保证表数据完全读取到 that.TableColumns[v.GetString("name")][info.GetString("name")] = coloum @@ -550,9 +511,12 @@ func (that *MakeCode) Db2JSON(db *db.HoTimeDB, config Map) { search := that.TableConfig.GetMap(fk).GetSlice("search") sv := Map{"type": "tree", "label": v["label"], "name": v["name"], "value": v["value"], "link": v["link"]} that.TableConfig.GetMap(fk)["search"] = append(search, sv) - that.SearchColumns[fk][k] = sv } + + if fk == that.FileConfig.GetString("table") && v["link"] != nil && that.TableColumns[v.GetString("link")]["parent_id"] != nil { + that.Config["stop"] = append(that.Config.GetSlice("stop"), v.GetString("link")) + } } } diff --git a/example/config/config.json b/example/config/config.json index 25953e7..4f15615 100644 --- a/example/config/config.json +++ b/example/config/config.json @@ -23,13 +23,13 @@ ], "db": { "mysql": { - "host": "192.168.2.20", - "name": "gov_crawler", - "password": "fh22y8b882d", + "host": "192.168.6.253", + "name": "dgs-cms", + "password": "dasda8454456", "port": "3306", "prefix": "", "user": "root" - + } }, "defFile": [ "index.html", diff --git a/example/config/config1.json b/example/config/config1.json deleted file mode 100644 index 63f1577..0000000 --- a/example/config/config1.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "cache": { - "db": { - "db": false, - "session": true, - "timeout": 7200 - }, - "memory": { - "db": true, - "session": true, - "timeout": 7200 - } - }, - "codeConfig": [ - { - "config": "config/admin.json", - "configDB": "config/adminDB.json", - "mode": 0, - "name": "", - "rule": "config/rule.json", - "table": "admin" - } - ], - "db": { - "mysql": { - "host": "192.168.2.20", - "name": "gov_crawler", - "password": "fh22y8b882d", - "port": "3306", - "prefix": "", - "user": "root" - } - }, - "defFile": [ - "index.html", - "index.htm" - ], - "error": { - "1": "内部系统异常", - "2": "访问权限异常", - "3": "请求参数异常", - "4": "数据处理异常", - "5": "数据结果异常" - }, - "mode": 2, - "port": "8081", - "sessionName": "HOTIME", - "tpt": "tpt" -} \ No newline at end of file