优化代码
This commit is contained in:
@@ -24,6 +24,23 @@ import (
|
||||
var {{table}}Ctr = Ctr{
|
||||
"info": func(that *Context) {
|
||||
re := that.Db.Get(that.RouterString[1], that.MakeCode.Info(that.RouterString[1]), Map{"id": that.RouterString[2]})
|
||||
|
||||
if re == nil {
|
||||
that.Display(4, "找不到对应信息")
|
||||
return
|
||||
}
|
||||
|
||||
for k, v := range re {
|
||||
|
||||
column:=that.MakeCode.TableColumns[that.RouterString[1]][k]
|
||||
if column==nil{
|
||||
continue
|
||||
}
|
||||
if (column["list"]==nil||column.GetBool("list"))&&column.GetString("link")!=""{
|
||||
re[column.GetString("link")] = that.Db.Get(column.GetString("link"), column.GetString("value"), Map{"id": v})
|
||||
}
|
||||
}
|
||||
|
||||
that.Display(0, re)
|
||||
},
|
||||
"add": func(that *Context) {
|
||||
@@ -70,7 +87,20 @@ var {{table}}Ctr = Ctr{
|
||||
columnStr, where := that.MakeCode.Search(that.RouterString[1], that.Req)
|
||||
reData := that.Db.Page(ObjToInt(that.Req.FormValue("page")), ObjToInt(that.Req.FormValue("pageRow"))).
|
||||
Select(that.RouterString[1], columnStr, where)
|
||||
for _, v := range reData {
|
||||
for k, _ := range v {
|
||||
column:=that.MakeCode.TableColumns[that.RouterString[1]][k]
|
||||
if column==nil{
|
||||
continue
|
||||
}
|
||||
|
||||
if (column["list"]==nil||column.GetBool("list"))&&column.GetString("link")!=""{
|
||||
v[column.GetString("link")] = that.Db.Get(column.GetString("link"), column.GetString("value"), Map{"id": v.GetCeilInt(k)})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
that.Display(0, reData)
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user