RecruitTool.py 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from alipay.aop.api.constant.ParamConstants import *
  5. from alipay.aop.api.domain.PidShopInfo import PidShopInfo
  6. class RecruitTool(object):
  7. def __init__(self):
  8. self._end_time = None
  9. self._exclude_constraint_shops = None
  10. self._pid_shops = None
  11. self._start_time = None
  12. @property
  13. def end_time(self):
  14. return self._end_time
  15. @end_time.setter
  16. def end_time(self, value):
  17. self._end_time = value
  18. @property
  19. def exclude_constraint_shops(self):
  20. return self._exclude_constraint_shops
  21. @exclude_constraint_shops.setter
  22. def exclude_constraint_shops(self, value):
  23. self._exclude_constraint_shops = value
  24. @property
  25. def pid_shops(self):
  26. return self._pid_shops
  27. @pid_shops.setter
  28. def pid_shops(self, value):
  29. if isinstance(value, list):
  30. self._pid_shops = list()
  31. for i in value:
  32. if isinstance(i, PidShopInfo):
  33. self._pid_shops.append(i)
  34. else:
  35. self._pid_shops.append(PidShopInfo.from_alipay_dict(i))
  36. @property
  37. def start_time(self):
  38. return self._start_time
  39. @start_time.setter
  40. def start_time(self, value):
  41. self._start_time = value
  42. def to_alipay_dict(self):
  43. params = dict()
  44. if self.end_time:
  45. if hasattr(self.end_time, 'to_alipay_dict'):
  46. params['end_time'] = self.end_time.to_alipay_dict()
  47. else:
  48. params['end_time'] = self.end_time
  49. if self.exclude_constraint_shops:
  50. if hasattr(self.exclude_constraint_shops, 'to_alipay_dict'):
  51. params['exclude_constraint_shops'] = self.exclude_constraint_shops.to_alipay_dict()
  52. else:
  53. params['exclude_constraint_shops'] = self.exclude_constraint_shops
  54. if self.pid_shops:
  55. if isinstance(self.pid_shops, list):
  56. for i in range(0, len(self.pid_shops)):
  57. element = self.pid_shops[i]
  58. if hasattr(element, 'to_alipay_dict'):
  59. self.pid_shops[i] = element.to_alipay_dict()
  60. if hasattr(self.pid_shops, 'to_alipay_dict'):
  61. params['pid_shops'] = self.pid_shops.to_alipay_dict()
  62. else:
  63. params['pid_shops'] = self.pid_shops
  64. if self.start_time:
  65. if hasattr(self.start_time, 'to_alipay_dict'):
  66. params['start_time'] = self.start_time.to_alipay_dict()
  67. else:
  68. params['start_time'] = self.start_time
  69. return params
  70. @staticmethod
  71. def from_alipay_dict(d):
  72. if not d:
  73. return None
  74. o = RecruitTool()
  75. if 'end_time' in d:
  76. o.end_time = d['end_time']
  77. if 'exclude_constraint_shops' in d:
  78. o.exclude_constraint_shops = d['exclude_constraint_shops']
  79. if 'pid_shops' in d:
  80. o.pid_shops = d['pid_shops']
  81. if 'start_time' in d:
  82. o.start_time = d['start_time']
  83. return o