hotime/example/app/category.go

35 lines
778 B
Go
Raw Normal View History

package app
import (
. "../../../hotime"
. "../../../hotime/common"
)
var categoryCtr = Ctr{
"info": func(that *Context) {
parentId := ObjToInt(that.Req.FormValue("id"))
//parentId := ObjToInt(that.RouterString[2])
2021-09-24 20:36:07 +00:00
childData := []Map{}
if parentId == 0 {
2021-09-11 21:35:14 +00:00
childData1 := that.Db.Select("category", "*", Map{"parent_id": nil})
for _, v := range childData1 {
data := that.Db.Get("category", "*", Map{"parent_id": v.GetCeilInt("id")})
2021-09-24 20:36:07 +00:00
if data != nil {
childData = append(childData, data)
}
2021-09-11 21:35:14 +00:00
2021-09-24 20:36:07 +00:00
}
2021-09-11 21:35:14 +00:00
2021-09-24 20:36:07 +00:00
} else {
2021-09-11 21:35:14 +00:00
childData = that.Db.Select("category", "*", Map{"parent_id": parentId})
}
for _, v := range childData {
v["child"] = that.Db.Select("category", "*", Map{"parent_id": v.GetCeilInt("id")})
}
that.Display(0, childData)
},
}