解决bug
This commit is contained in:
parent
9425544d1c
commit
7419e03d67
106
code.go
106
code.go
@ -740,51 +740,53 @@ var TptProject = Proj{
|
||||
|
||||
linkAuthMap := that.Db.Get(v.GetString("link"), "auth", Map{"id": user.GetCeilInt(v.GetString("name"))})
|
||||
linkAuth := linkAuthMap.GetMap("auth")
|
||||
//conf := ObjToMap(string(btes))
|
||||
//menus := conf.GetSlice("menus")
|
||||
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 {
|
||||
for k1, _ := range menus {
|
||||
v1 := menus.GetMap(k1)
|
||||
name := v1.GetString("name")
|
||||
if name == "" {
|
||||
name = v1.GetString("table")
|
||||
}
|
||||
if v1["auth"] != nil {
|
||||
|
||||
if linkAuth[name] == 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"}
|
||||
} else {
|
||||
newAuth := Slice{}
|
||||
for k2, _ := range linkAuth.GetSlice(name) {
|
||||
v2 := linkAuth.GetSlice(name).GetString(k2)
|
||||
if strings.Contains(v1.GetString("auth"), v2) {
|
||||
newAuth = append(newAuth, v2)
|
||||
}
|
||||
}
|
||||
linkAuth[name] = newAuth
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
newAuth := Slice{}
|
||||
for k3, _ := range linkAuth.GetSlice(name) {
|
||||
v3 := linkAuth.GetSlice(name).GetString(k3)
|
||||
if strings.Contains(v2.GetString("auth"), v3) {
|
||||
newAuth = append(newAuth, v3)
|
||||
}
|
||||
}
|
||||
linkAuth[name] = newAuth
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
for k1, _ := range menus {
|
||||
@ -793,29 +795,31 @@ var TptProject = Proj{
|
||||
if fileConfig.GetString("table") == v1.GetString("table") {
|
||||
v1["auth"] = Slice{"info", "edit"}
|
||||
}
|
||||
name := v1.GetString("name")
|
||||
if name == "" {
|
||||
name = v1.GetString("table")
|
||||
}
|
||||
|
||||
if linkAuth[v1.GetString("name")] != nil {
|
||||
v1["auth"] = linkAuth[v1.GetString("name")]
|
||||
}
|
||||
if linkAuth[v1.GetString("table")] != nil {
|
||||
v1["auth"] = linkAuth[v1.GetString("table")]
|
||||
if linkAuth[name] != nil {
|
||||
v1["auth"] = linkAuth[name]
|
||||
}
|
||||
|
||||
v1menus := v1.GetSlice("menus")
|
||||
for k2, _ := range v1menus {
|
||||
v2 := v1menus.GetMap(k2)
|
||||
|
||||
//保证个人权限可用
|
||||
if fileConfig.GetString("table") == v2.GetString("table") {
|
||||
v2["auth"] = Slice{"info", "edit"}
|
||||
|
||||
}
|
||||
name := v2.GetString("name")
|
||||
if name == "" {
|
||||
name = v2.GetString("table")
|
||||
}
|
||||
if linkAuth[name] != nil {
|
||||
v2["auth"] = linkAuth[name]
|
||||
}
|
||||
|
||||
if linkAuth[v2.GetString("name")] != nil {
|
||||
v2["auth"] = linkAuth[v2.GetString("name")]
|
||||
}
|
||||
if linkAuth[v2.GetString("table")] != nil {
|
||||
v2["auth"] = linkAuth[v2.GetString("table")]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -831,14 +835,14 @@ var TptProject = Proj{
|
||||
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 {
|
||||
if config.GetMap("tables").GetMap(v1.GetString("table")) != nil && len(v1.GetSlice("auth")) != 0 {
|
||||
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 config.GetMap("tables").GetMap(v2.GetString("table")) != nil && len(v2.GetSlice("auth")) != 0 {
|
||||
|
||||
//有自定义配置文件
|
||||
if conf.GetMap("tables") != nil && conf.GetMap("tables").GetMap(v2.GetString("table")) != nil {
|
||||
|
@ -371,14 +371,14 @@ func (that *MakeCode) Db2JSON(db *db.HoTimeDB, config Map) {
|
||||
|
||||
prefixName = DefaultMenuParentName + ":" + prefixName
|
||||
|
||||
menuIns := Map{"label": that.TableConfig.GetMap(fk).GetString("label"), "table": fk}
|
||||
menuIns := Map{"label": that.TableConfig.GetMap(fk).GetString("label"), "table": fk, "auth": that.TableConfig.GetMap(fk).GetSlice("auth")}
|
||||
//多耗费一点内存
|
||||
mMenu := Map{"menus": Slice{menuIns}, "label": that.TableConfig.GetMap(fk).GetString("label"), "name": prefixName, "icon": "el-icon-setting"}
|
||||
mMenu := Map{"menus": Slice{menuIns}, "auth": Slice{"show"}, "label": that.TableConfig.GetMap(fk).GetString("label"), "name": prefixName, "icon": "el-icon-setting"}
|
||||
//表名有前缀
|
||||
if !isNewPrefix {
|
||||
//是否已有对应前缀,已经有对应的menu只需要push进去即可
|
||||
prefixName = DefaultMenuParentName
|
||||
mMenu = Map{"menus": Slice{menuIns}, "label": "系统管理", "name": prefixName, "icon": "el-icon-setting"}
|
||||
mMenu = Map{"menus": Slice{menuIns}, "auth": Slice{"show"}, "label": "系统管理", "name": prefixName, "icon": "el-icon-setting"}
|
||||
}
|
||||
//没有新前缀
|
||||
if that.IndexMenus[prefixName] != nil {
|
||||
@ -1103,7 +1103,3 @@ func (that *MakeCode) Search(table string, userData Map, req *http.Request, db *
|
||||
|
||||
return reStr, leftJoin, where
|
||||
}
|
||||
|
||||
func setListener() {
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user