TreeData.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from alipay.aop.api.constant.ParamConstants import *
  5. class TreeData(object):
  6. def __init__(self):
  7. self._cooperation = None
  8. self._num = None
  9. self._tree_alias = None
  10. self._tree_type = None
  11. @property
  12. def cooperation(self):
  13. return self._cooperation
  14. @cooperation.setter
  15. def cooperation(self, value):
  16. self._cooperation = value
  17. @property
  18. def num(self):
  19. return self._num
  20. @num.setter
  21. def num(self, value):
  22. self._num = value
  23. @property
  24. def tree_alias(self):
  25. return self._tree_alias
  26. @tree_alias.setter
  27. def tree_alias(self, value):
  28. self._tree_alias = value
  29. @property
  30. def tree_type(self):
  31. return self._tree_type
  32. @tree_type.setter
  33. def tree_type(self, value):
  34. self._tree_type = value
  35. def to_alipay_dict(self):
  36. params = dict()
  37. if self.cooperation:
  38. if hasattr(self.cooperation, 'to_alipay_dict'):
  39. params['cooperation'] = self.cooperation.to_alipay_dict()
  40. else:
  41. params['cooperation'] = self.cooperation
  42. if self.num:
  43. if hasattr(self.num, 'to_alipay_dict'):
  44. params['num'] = self.num.to_alipay_dict()
  45. else:
  46. params['num'] = self.num
  47. if self.tree_alias:
  48. if hasattr(self.tree_alias, 'to_alipay_dict'):
  49. params['tree_alias'] = self.tree_alias.to_alipay_dict()
  50. else:
  51. params['tree_alias'] = self.tree_alias
  52. if self.tree_type:
  53. if hasattr(self.tree_type, 'to_alipay_dict'):
  54. params['tree_type'] = self.tree_type.to_alipay_dict()
  55. else:
  56. params['tree_type'] = self.tree_type
  57. return params
  58. @staticmethod
  59. def from_alipay_dict(d):
  60. if not d:
  61. return None
  62. o = TreeData()
  63. if 'cooperation' in d:
  64. o.cooperation = d['cooperation']
  65. if 'num' in d:
  66. o.num = d['num']
  67. if 'tree_alias' in d:
  68. o.tree_alias = d['tree_alias']
  69. if 'tree_type' in d:
  70. o.tree_type = d['tree_type']
  71. return o