list_contoller.go 586 B

12345678910111213141516171819202122232425262728293031
  1. package controllers
  2. import (
  3. "eta_mini_ht_api/common/contants"
  4. "eta_mini_ht_api/common/utils/page"
  5. )
  6. type ListController struct {
  7. BaseController
  8. PageInfo page.PageInfo
  9. }
  10. func (l *ListController) Prepare() {
  11. pageSize, _ := l.GetInt("page_size")
  12. currentIndex, _ := l.GetInt("current_index")
  13. LatestId, _ := l.GetInt64("latest_id")
  14. if pageSize <= 0 {
  15. pageSize = contants.PageSizeDefault
  16. }
  17. if currentIndex <= 0 {
  18. currentIndex = 1
  19. }
  20. if LatestId < 0 {
  21. LatestId = 0
  22. }
  23. l.PageInfo = page.PageInfo{
  24. LatestId: LatestId,
  25. Current: currentIndex,
  26. PageSize: pageSize,
  27. }
  28. }