diff --git a/code/config.go b/code/config.go index 5bb1bac..6ea2930 100644 --- a/code/config.go +++ b/code/config.go @@ -15,7 +15,9 @@ var Config = Map{ "menu": []Map{ {"label": "用户管理", "table": "user"}, {"label": "组织管理", "table": "organization"}, + {"label": "地区管理", "table": "area"}, {"label": "角色管理", "table": "role"}, + {"label": "日志管理", "table": "log"}, {"label": "系统设置", "table": "system", "default": "edit"}, }, }, diff --git a/code/makecode.go b/code/makecode.go index f82a156..80cbb00 100644 --- a/code/makecode.go +++ b/code/makecode.go @@ -41,20 +41,22 @@ func (that *MakeCode) Db2JSON(name string, path string, db db.HoTimeDB) { } else { that.Error.SetError(errors.New("配置文件不存在,或者配置出错,使用缺省默认配置")) } - tables := that.Config.GetSlice("tables") - that.TableConfig = Map{} - for k, _ := range tables { - tableName := tables.GetMap(k).GetString("table") - that.TableConfig[tableName] = tables.GetMap(k) - columns := tables.GetMap(k).GetSlice("columns") + that.TableConfig = that.Config.GetMap("tables") + if that.TableConfig == nil { + that.TableConfig = Map{} + } + + for tableName, _ := range that.TableConfig { + + columns := that.TableConfig.GetMap(tableName).GetSlice("columns") //初始化 if that.TableColumns[tableName] == nil { that.TableColumns[tableName] = map[string]Map{} } //注入源数据 - for k, _ := range columns { - columnsName := columns.GetMap(k).GetString("name") - that.TableColumns[tableName][columnsName] = columns.GetMap(k) + for index, _ := range columns { + columnsName := columns.GetMap(index).GetString("name") + that.TableColumns[tableName][columnsName] = columns.GetMap(index) } } @@ -117,25 +119,26 @@ func (that *MakeCode) Db2JSON(name string, path string, db db.HoTimeDB) { if info.GetString("label") == "" { info["label"] = "备注" } - coloums := that.TableColumns[v.GetString("name")][info.GetString("name")] + coloum := that.TableColumns[v.GetString("name")][info.GetString("name")] - if coloums == nil { - coloums = Map{ + if coloum == nil { + coloum = Map{ "name": info.GetString("name"), "type": info.GetString("type"), "label": info.GetString("label"), //"add": false, "info": false, "edit": false, "list": true, "must": false, } + that.TableConfig.GetMap(v.GetString("name"))["columns"] = append(that.TableConfig.GetMap(v.GetString("name")).GetSlice("columns"), coloum) } else { - if !(coloums.GetString("label") != "备注" && info.GetString("label") == "备注") { - coloums["label"] = info.GetString("label") + if !(coloum.GetString("label") != "备注" && info.GetString("label") == "备注") { + coloum["label"] = info.GetString("label") } - coloums["type"] = info.GetString("type") + coloum["type"] = info.GetString("type") } - that.TableColumns[v.GetString("name")][info.GetString("name")] = coloums + that.TableColumns[v.GetString("name")][info.GetString("name")] = coloum } @@ -158,20 +161,8 @@ func (that *MakeCode) Db2JSON(name string, path string, db db.HoTimeDB) { } - newTables := []Map{} - for k, _ := range that.TableConfig { - newTable := that.TableConfig.GetMap(k) - newTables = append(newTables, newTable) - columns := []Map{} - for _, v := range that.TableColumns[newTable.GetString("table")] { - columns = append(columns, v) - } - newTable["columns"] = columns - } - that.Config["tables"] = newTables + that.Config["tables"] = that.TableConfig - //} - //fmt.Println(ObjToStr(idSlice)) id := Md5(ObjToStr(idSlice)) if id == that.Config.GetString("id") { diff --git a/example/config/config.json b/example/config/config.json index 3415642..7d9edf8 100644 --- a/example/config/config.json +++ b/example/config/config.json @@ -9,6 +9,7 @@ "codeConfig": { "admin": "config/app.json" }, + "crossDomain": "auto", "db": { "mysql": { "host": "192.168.6.250", diff --git a/example/main.go b/example/main.go index 885be50..32c7ba0 100644 --- a/example/main.go +++ b/example/main.go @@ -62,6 +62,7 @@ func main() { "app": hotime.Proj{ "index": hotime.Ctr{ "test": func(this *hotime.Context) { + data := this.Db.Get("cached", "*") fmt.Println(data) fmt.Println(this.Session("test").ToCeilInt())