controller包下: func (c *Area)List() { id, _ := c.GetInt("parent_id") //查询 where := make(map[string]interface{}) where["parent_id"] = id //初始化 mod := admin.NewAreaService() //查询 page, _ := c.GetInt("page") data, err := model.GetAll(where, []string{}, "id ASC", page, 999) if err != nil { fmt.Println(err.Error()) c.Error(err.Error()) return } c.Data["data"] = data //扩展查询 ext := admin.NewAreaExtService() data_ext, err := ext.GetAll(where, []string{}, "id ASC,ext_id ASC", page, 999) if err != nil { c.Error(err.Error()) return } c.Data["data_ext"] = data_ext c.Data["title"] = "地区-列表" c.TplName = "admin/areast.html" } model包下: func (c *Area) GetAll(q map[string]interface{}, fields []string, orderBy string, page int, limit int) (*db.Paginator, error) { session := db.Filter(q) count, err := session.Count(c) if err != nil { fmt.Println(err) return nil,fox.NewError( err.Error()) } Query := db.Pagination(int(count), page, limit) if count == 0 { return Query, nil } session = db.Filter(q) if orderBy != "" { session.OrderBy(orderBy) } session.Limit(limit, Query.Offset) if len(fields) == 0 { session.AllCols() } data := c.newMakeDataArr() err = session.Find(&data) if err != nil { fmt.Println(err) return nil,fox.NewError( err.Error()) } Query.Data = make([]interface{}, len(data)) for y, x := range data { Query.Data[y] = x } return Query, nil } 编译错误: F:\jgn02\src\blog>go build main.go # blog/controllers/admin controllers\admin\area.go:26:15: undefined: model
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- 主机ping不通克隆的虚拟机
- 容器网络通,但业务网络不通,怎么办?
- 支撑无服务器计算,传统存储方案已经行不通了
- 记一次VMware 虚拟机与宿主机网络互ping不通问题解决
- “狗屁不通文章生成器”在GitHub热榜火了:文章真够啰嗦的
- 从对ML一窍不通到斩获AT等special offer,拿下大厂算法岗就靠它了
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
HTTP Developer's Handbook
Chris Shiflett / Sams Publishing / 2003-3-29 / USD 39.99
The largest group with an unsatisfied demand for a good book on HTTP is the worldwide group of Web developers. A good book on HTTP can help new and old Web developers alike, as a thorough understandin......一起来看看 《HTTP Developer's Handbook》 这本书的介绍吧!