PageInfo.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from alipay.aop.api.constant.ParamConstants import *
  5. class PageInfo(object):
  6. def __init__(self):
  7. self._current = None
  8. self._page_size = None
  9. self._total = None
  10. @property
  11. def current(self):
  12. return self._current
  13. @current.setter
  14. def current(self, value):
  15. self._current = value
  16. @property
  17. def page_size(self):
  18. return self._page_size
  19. @page_size.setter
  20. def page_size(self, value):
  21. self._page_size = value
  22. @property
  23. def total(self):
  24. return self._total
  25. @total.setter
  26. def total(self, value):
  27. self._total = value
  28. def to_alipay_dict(self):
  29. params = dict()
  30. if self.current:
  31. if hasattr(self.current, 'to_alipay_dict'):
  32. params['current'] = self.current.to_alipay_dict()
  33. else:
  34. params['current'] = self.current
  35. if self.page_size:
  36. if hasattr(self.page_size, 'to_alipay_dict'):
  37. params['page_size'] = self.page_size.to_alipay_dict()
  38. else:
  39. params['page_size'] = self.page_size
  40. if self.total:
  41. if hasattr(self.total, 'to_alipay_dict'):
  42. params['total'] = self.total.to_alipay_dict()
  43. else:
  44. params['total'] = self.total
  45. return params
  46. @staticmethod
  47. def from_alipay_dict(d):
  48. if not d:
  49. return None
  50. o = PageInfo()
  51. if 'current' in d:
  52. o.current = d['current']
  53. if 'page_size' in d:
  54. o.page_size = d['page_size']
  55. if 'total' in d:
  56. o.total = d['total']
  57. return o