优化代码
This commit is contained in:
parent
4038598470
commit
642bf97272
@ -15,7 +15,9 @@ var Config = Map{
|
|||||||
"menu": []Map{
|
"menu": []Map{
|
||||||
{"label": "用户管理", "table": "user"},
|
{"label": "用户管理", "table": "user"},
|
||||||
{"label": "组织管理", "table": "organization"},
|
{"label": "组织管理", "table": "organization"},
|
||||||
|
{"label": "地区管理", "table": "area"},
|
||||||
{"label": "角色管理", "table": "role"},
|
{"label": "角色管理", "table": "role"},
|
||||||
|
{"label": "日志管理", "table": "log"},
|
||||||
{"label": "系统设置", "table": "system", "default": "edit"},
|
{"label": "系统设置", "table": "system", "default": "edit"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -41,20 +41,22 @@ func (that *MakeCode) Db2JSON(name string, path string, db db.HoTimeDB) {
|
|||||||
} else {
|
} else {
|
||||||
that.Error.SetError(errors.New("配置文件不存在,或者配置出错,使用缺省默认配置"))
|
that.Error.SetError(errors.New("配置文件不存在,或者配置出错,使用缺省默认配置"))
|
||||||
}
|
}
|
||||||
tables := that.Config.GetSlice("tables")
|
that.TableConfig = that.Config.GetMap("tables")
|
||||||
that.TableConfig = Map{}
|
if that.TableConfig == nil {
|
||||||
for k, _ := range tables {
|
that.TableConfig = Map{}
|
||||||
tableName := tables.GetMap(k).GetString("table")
|
}
|
||||||
that.TableConfig[tableName] = tables.GetMap(k)
|
|
||||||
columns := tables.GetMap(k).GetSlice("columns")
|
for tableName, _ := range that.TableConfig {
|
||||||
|
|
||||||
|
columns := that.TableConfig.GetMap(tableName).GetSlice("columns")
|
||||||
//初始化
|
//初始化
|
||||||
if that.TableColumns[tableName] == nil {
|
if that.TableColumns[tableName] == nil {
|
||||||
that.TableColumns[tableName] = map[string]Map{}
|
that.TableColumns[tableName] = map[string]Map{}
|
||||||
}
|
}
|
||||||
//注入源数据
|
//注入源数据
|
||||||
for k, _ := range columns {
|
for index, _ := range columns {
|
||||||
columnsName := columns.GetMap(k).GetString("name")
|
columnsName := columns.GetMap(index).GetString("name")
|
||||||
that.TableColumns[tableName][columnsName] = columns.GetMap(k)
|
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") == "" {
|
if info.GetString("label") == "" {
|
||||||
info["label"] = "备注"
|
info["label"] = "备注"
|
||||||
}
|
}
|
||||||
coloums := that.TableColumns[v.GetString("name")][info.GetString("name")]
|
coloum := that.TableColumns[v.GetString("name")][info.GetString("name")]
|
||||||
|
|
||||||
if coloums == nil {
|
if coloum == nil {
|
||||||
coloums = Map{
|
coloum = Map{
|
||||||
"name": info.GetString("name"),
|
"name": info.GetString("name"),
|
||||||
"type": info.GetString("type"),
|
"type": info.GetString("type"),
|
||||||
"label": info.GetString("label"),
|
"label": info.GetString("label"),
|
||||||
//"add": false, "info": false, "edit": false, "list": true,
|
//"add": false, "info": false, "edit": false, "list": true,
|
||||||
"must": false,
|
"must": false,
|
||||||
}
|
}
|
||||||
|
that.TableConfig.GetMap(v.GetString("name"))["columns"] = append(that.TableConfig.GetMap(v.GetString("name")).GetSlice("columns"), coloum)
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if !(coloums.GetString("label") != "备注" && info.GetString("label") == "备注") {
|
if !(coloum.GetString("label") != "备注" && info.GetString("label") == "备注") {
|
||||||
coloums["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{}
|
that.Config["tables"] = that.TableConfig
|
||||||
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
|
|
||||||
|
|
||||||
//}
|
|
||||||
//fmt.Println(ObjToStr(idSlice))
|
|
||||||
id := Md5(ObjToStr(idSlice))
|
id := Md5(ObjToStr(idSlice))
|
||||||
|
|
||||||
if id == that.Config.GetString("id") {
|
if id == that.Config.GetString("id") {
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
"codeConfig": {
|
"codeConfig": {
|
||||||
"admin": "config/app.json"
|
"admin": "config/app.json"
|
||||||
},
|
},
|
||||||
|
"crossDomain": "auto",
|
||||||
"db": {
|
"db": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"host": "192.168.6.250",
|
"host": "192.168.6.250",
|
||||||
|
@ -62,6 +62,7 @@ func main() {
|
|||||||
"app": hotime.Proj{
|
"app": hotime.Proj{
|
||||||
"index": hotime.Ctr{
|
"index": hotime.Ctr{
|
||||||
"test": func(this *hotime.Context) {
|
"test": func(this *hotime.Context) {
|
||||||
|
|
||||||
data := this.Db.Get("cached", "*")
|
data := this.Db.Get("cached", "*")
|
||||||
fmt.Println(data)
|
fmt.Println(data)
|
||||||
fmt.Println(this.Session("test").ToCeilInt())
|
fmt.Println(this.Session("test").ToCeilInt())
|
||||||
|
Loading…
Reference in New Issue
Block a user