func (this *UserController) getP(str string) string { count := m.GetUserCount() pager := this.paginator(PAGE_SIZE, count) total := pager.PageNums() cur, _ := strconv.Atoi(str) //如果当获取的页数大于总页数 if cur > total { str = strconv.Itoa(total) } return str }
// user list func (this *UserController) UserList() { // paginator count := m.GetUserCount() pager := this.paginator(PAGE_SIZE, count) users, _ := m.GetUserList(pager.Offset(), PAGE_SIZE, "userId") this.Data["Users"] = &users p := this.GetString("p") if p == "" { p = `1` } this.Data["p"] = p this.Layout = INDEX this.TplNames = "admin/userList.html" }