好吧,這就是應用於我上一篇文章分頁組件使用的後端前端
承接上文,使用我這篇記錄裏的不嚴謹案例後端
func PageGetAll(engine *xorm.Engine,limit,index int)(addrList []*MailBoxAddress,total int64,err error){ total,err =engine.Table("mailboxes").Alias("box"). Join("INNER",[]string{"buildings","mailbuilding"},"box.building_id = mailbuilding.id"). Join("INNER","links","box.id = links.mailbox_id"). Join("INNER","buildings","links.building_id = buildings.id"). Count(new(MailBoxAddress)) if err !=nil{ return } err = engine.Table("mailboxes").Alias("box").Select("box.*, mailbuilding.addr,buildings.*,links.*"). Join("INNER",[]string{"buildings","mailbuilding"},"box.building_id = mailbuilding.id"). Join("INNER","links","box.id = links.mailbox_id"). Join("INNER","buildings","links.building_id = buildings.id"). Limit(limit,index*limit).Find(&addList) return }
之因此在代碼中返回全部item的數量,是爲了前端實現分頁效果。ui