框架优化
This commit is contained in:
@@ -12,7 +12,7 @@ var TptProject = Proj{
|
||||
"info": func(that *Context) {
|
||||
hotimeName := that.RouterString[0]
|
||||
fileConfig := that.MakeCodeRouter[hotimeName].FileConfig
|
||||
data := that.Db.Get(hotimeName, "*", Map{"id": that.Session(fileConfig.GetString("table") + "_id").ToCeilInt()})
|
||||
data := that.Db.Get(fileConfig.GetString("table"), "*", Map{"id": that.Session(fileConfig.GetString("table") + "_id").ToCeilInt()})
|
||||
str, inData := that.MakeCodeRouter[hotimeName].Info(that.RouterString[1], data, that.Db)
|
||||
where := Map{"id": that.RouterString[2]}
|
||||
|
||||
@@ -36,16 +36,46 @@ var TptProject = Proj{
|
||||
if column == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
if (column["list"] == nil || column.GetBool("list")) && column.GetString("link") != "" {
|
||||
re[column.GetString("link")] = that.Db.Get(column.GetString("link"), "id,"+column.GetString("value"), Map{"id": v})
|
||||
seStr:="id,"+column.GetString("value")
|
||||
if that.MakeCodeRouter[hotimeName].TableColumns[column.GetString("link")]["phone"]!=nil{
|
||||
seStr=seStr+",phone"
|
||||
}
|
||||
|
||||
link:=strings.Replace(column.GetString("name"),"_id","",-1)
|
||||
|
||||
re[link] = that.Db.Get(column.GetString("link"), seStr, Map{"id": v})
|
||||
}
|
||||
}
|
||||
|
||||
//如果有table字段则代为link
|
||||
if re["table"]!=nil&&re["table_id"]!=nil {
|
||||
|
||||
column := that.MakeCodeRouter[hotimeName].TableColumns[that.RouterString[1]][re.GetString("table")]
|
||||
v:=re.GetCeilInt64("table_id")
|
||||
|
||||
seStr:="id,"+column.GetString("value")
|
||||
|
||||
if that.MakeCodeRouter[hotimeName].TableColumns[column.GetString("link")]["phone"]!=nil{
|
||||
seStr=seStr+",phone"
|
||||
}
|
||||
|
||||
link:=strings.Replace(column.GetString("name"),"_id","",-1)
|
||||
|
||||
re[link] = that.Db.Get(column.GetString("link"), seStr, Map{"id": v})
|
||||
|
||||
}
|
||||
|
||||
that.Display(0, re)
|
||||
},
|
||||
"add": func(that *Context) {
|
||||
that.Log=Map{"table":that.RouterString[1],"type":1}
|
||||
|
||||
hotimeName := that.RouterString[0]
|
||||
inData := that.MakeCodeRouter[hotimeName].Add(that.RouterString[1], that.Req)
|
||||
fileConfig := that.MakeCodeRouter[hotimeName].FileConfig
|
||||
data := that.Db.Get(fileConfig.GetString("table"), "*", Map{"id": that.Session(fileConfig.GetString("table") + "_id").ToCeilInt()})
|
||||
inData := that.MakeCodeRouter[hotimeName].Add(that.RouterString[1],data, that.Req)
|
||||
if inData == nil {
|
||||
that.Display(3, "请求参数不足")
|
||||
return
|
||||
@@ -66,12 +96,17 @@ var TptProject = Proj{
|
||||
inData["index"] = "," + ObjToStr(re) + ","
|
||||
that.Db.Update(that.RouterString[1], Map{"index": inData["index"]}, Map{"id": re})
|
||||
}
|
||||
|
||||
that.Log["table_id"]=re
|
||||
that.Display(0, re)
|
||||
},
|
||||
"update": func(that *Context) {
|
||||
|
||||
that.Log=Map{"table":that.RouterString[1],"type":2,"table_id":that.RouterString[2]}
|
||||
|
||||
hotimeName := that.RouterString[0]
|
||||
inData := that.MakeCodeRouter[hotimeName].Edit(that.RouterString[1], that.Req)
|
||||
|
||||
|
||||
if inData == nil {
|
||||
that.Display(3, "没有找到要更新的数据")
|
||||
return
|
||||
@@ -106,6 +141,7 @@ var TptProject = Proj{
|
||||
that.Display(0, re)
|
||||
},
|
||||
"remove": func(that *Context) {
|
||||
that.Log=Map{"table":that.RouterString[1],"type":3,"table_id":that.RouterString[2]}
|
||||
hotimeName := that.RouterString[0]
|
||||
inData := that.MakeCodeRouter[hotimeName].Delete(that.RouterString[1], that.Req)
|
||||
if inData == nil {
|
||||
@@ -131,7 +167,7 @@ var TptProject = Proj{
|
||||
hotimeName := that.RouterString[0]
|
||||
fileConfig := that.MakeCodeRouter[hotimeName].FileConfig
|
||||
|
||||
data := that.Db.Get(hotimeName, "*", Map{"id": that.Session(fileConfig.GetString("table") + "_id").ToCeilInt()})
|
||||
data := that.Db.Get(fileConfig.GetString("table"), "*", Map{"id": that.Session(fileConfig.GetString("table") + "_id").ToCeilInt()})
|
||||
|
||||
columnStr, leftJoin, where := that.MakeCodeRouter[hotimeName].Search(that.RouterString[1], data, that.Req, that.Db)
|
||||
|
||||
@@ -152,13 +188,27 @@ var TptProject = Proj{
|
||||
|
||||
for _, v := range reData {
|
||||
v.RangeSort(func(k string, v1 interface{}) (isEnd bool) {
|
||||
//for k, _ := range v {
|
||||
//如果有table字段则代为link
|
||||
if v["table"]!=nil&&v["table_id"]!=nil {
|
||||
|
||||
id:=v.GetCeilInt64("table_id")
|
||||
tableName := that.MakeCodeRouter[hotimeName].TableConfig.GetMap(v.GetString("table")).GetString("label")
|
||||
v["table_table_name"]=strings.Replace(tableName,"管理","",-1)
|
||||
parentC := that.Db.Get(v.GetString("table"), "name", Map{"id": id})
|
||||
v["table_table_id_name"] = ""
|
||||
if parentC != nil {
|
||||
v["table_table_id_name"]= parentC.GetString("name")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
column := that.MakeCodeRouter[hotimeName].TableColumns[that.RouterString[1]][k]
|
||||
if column == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
if column["list"] != false && column["name"] == "parent_id" && column.GetString("link") != "" {
|
||||
|
||||
parentC := that.Db.Get(column.GetString("link"), column.GetString("value"), Map{"id": v.GetCeilInt(k)})
|
||||
v[column.GetString("link")+"_"+column.GetString("name")+"_"+column.GetString("value")] = ""
|
||||
if parentC != nil {
|
||||
@@ -166,7 +216,6 @@ var TptProject = Proj{
|
||||
}
|
||||
}
|
||||
|
||||
//}
|
||||
return isEnd
|
||||
})
|
||||
}
|
||||
@@ -207,7 +256,7 @@ var TptProject = Proj{
|
||||
hotimeName := that.RouterString[0]
|
||||
fileConfig := that.MakeCodeRouter[hotimeName].FileConfig
|
||||
|
||||
data := that.Db.Get(hotimeName, "*", Map{"id": that.Session(fileConfig.GetString("table") + "_id").ToCeilInt()})
|
||||
data := that.Db.Get(fileConfig.GetString("table"), "*", Map{"id": that.Session(fileConfig.GetString("table") + "_id").ToCeilInt()})
|
||||
str, inData := that.MakeCodeRouter[hotimeName].Info(fileConfig.GetString("table"), data, that.Db)
|
||||
where := Map{"id": that.Session(fileConfig.GetString("table") + "_id").ToCeilInt()}
|
||||
if len(inData) == 1 {
|
||||
|
||||
Reference in New Issue
Block a user