list_contoller.go 694 B

12345678910111213141516171819202122232425262728293031323334353637
  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("pageSize")
  12. currentIndex, _ := l.GetInt("currentIndex")
  13. LatestId, _ := l.GetInt64("latestId")
  14. total, _ := l.GetInt64("total")
  15. if pageSize <= 0 {
  16. pageSize = contants.PageSizeDefault
  17. }
  18. if currentIndex <= 0 {
  19. currentIndex = 1
  20. }
  21. if LatestId < 0 {
  22. LatestId = 0
  23. }
  24. l.PageInfo = page.PageInfo{
  25. LatestId: LatestId,
  26. Current: currentIndex,
  27. PageSize: pageSize,
  28. Total: total,
  29. }
  30. }
  31. func (l *ListController) Finish() {
  32. l.PageInfo.Reset()
  33. }