package service import ( "beeblog/models" "github.com/astaxie/beego/orm" "fmt" ) func FindCommentByBlog(bid int64) ([]*models.Comment, error) { var comms []*models.Comment o := orm.NewOrm() _, err := o.QueryTable(&models.Comment{}).Filter("Pid", 0).Filter("BlogId",bid).OrderBy("-Ctime").All(&comms) if err != nil { return nil, err } if len(comms) > 0 { for i := 0; i < len(comms); i++ { var childs []*models.Comment _, childerrr := o.QueryTable(&models.Comment{}).Filter("Pid", comms[i].Id).OrderBy("-Ctime").All(&childs) if childerrr == nil { if len(childs) > 0{ comms[i].Childs = childs for j:=0 ; j