分页查找标签.
(pageIndex, pageSize int, word ...string)
| 67 | |
| 68 | //分页查找标签. |
| 69 | func (m *Label) FindToPager(pageIndex, pageSize int, word ...string) (labels []*Label, totalCount int, err error) { |
| 70 | var count int64 |
| 71 | o := orm.NewOrm() |
| 72 | q := o.QueryTable(m.TableNameWithPrefix()).OrderBy("-book_number") |
| 73 | if len(word) > 0 { |
| 74 | q = q.Filter("label_name__icontains", word[0]) |
| 75 | } |
| 76 | count, err = q.Count() |
| 77 | if err != nil { |
| 78 | return |
| 79 | } |
| 80 | totalCount = int(count) |
| 81 | |
| 82 | offset := (pageIndex - 1) * pageSize |
| 83 | |
| 84 | _, err = q.Offset(offset).Limit(pageSize).All(&labels) |
| 85 | |
| 86 | return |
| 87 | } |
nothing calls this directly
no test coverage detected