RulesObj.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <?php
  2. namespace common\util;
  3. use common\models\Rules;
  4. use JsonSerializable;
  5. /**
  6. * Class RulesObj
  7. * @package common\util
  8. * @property int $id
  9. * @property string $rule_name
  10. * @property string $rule_content
  11. * @property string $rule_category
  12. * @property int $rule_status
  13. * @property string $create_time
  14. * @property string $update_time
  15. * @property string $version
  16. */
  17. class RulesObj implements JsonSerializable
  18. {
  19. private $id;
  20. private $rule_name;
  21. private $rule_category;
  22. private $rule_content;
  23. private $rule_status;
  24. private $create_time;
  25. private $end_time;
  26. private $update_time;
  27. private $version;
  28. /**
  29. * @return int
  30. */
  31. public function getId(): int
  32. {
  33. return $this->id;
  34. }
  35. /**
  36. * @param int $id
  37. */
  38. public function setId(int $id)
  39. {
  40. $this->id = $id;
  41. }
  42. /**
  43. * @return string
  44. */
  45. public function getRuleName(): string
  46. {
  47. return $this->rule_name;
  48. }
  49. /**
  50. * @param string $rule_name
  51. */
  52. public function setRuleName(string $rule_name)
  53. {
  54. $this->rule_name = $rule_name;
  55. }
  56. /**
  57. * @return string
  58. */
  59. public function getRuleCategory(): string
  60. {
  61. return $this->rule_category;
  62. }
  63. /**
  64. * @param string $rule_category
  65. */
  66. public function setRuleCategory(string $rule_category)
  67. {
  68. $this->rule_category = $rule_category;
  69. }
  70. /**
  71. * @return int
  72. */
  73. public function getRuleStatus(): int
  74. {
  75. return $this->rule_status;
  76. }
  77. /**
  78. * @param int $rule_status
  79. */
  80. public function setRuleStatus(int $rule_status)
  81. {
  82. $this->rule_status = $rule_status;
  83. }
  84. /**
  85. * @return string
  86. */
  87. public function getCreateTime(): string
  88. {
  89. return $this->create_time;
  90. }
  91. /**
  92. * @param string $create_time
  93. */
  94. public function setCreateTime(string $create_time)
  95. {
  96. $this->create_time = $create_time;
  97. }
  98. /**
  99. * @return string
  100. */
  101. public function getUpdateTime(): string
  102. {
  103. return $this->update_time;
  104. }
  105. /**
  106. * @param string $update_time
  107. */
  108. public function setUpdateTime(string $update_time)
  109. {
  110. $this->update_time = $update_time;
  111. }
  112. /**
  113. * @return string
  114. */
  115. public function getVersion(): string
  116. {
  117. return $this->version;
  118. }
  119. /**
  120. * @param string $version
  121. */
  122. public function setVersion(string $version)
  123. {
  124. $this->version = $version;
  125. }
  126. public function __construct(Rules $rules)
  127. {
  128. $this->id = $rules->id;
  129. $this->rule_name = $rules->rule_name;
  130. $this->rule_content = $rules->rule_content;
  131. $this->rule_category = $rules->rule_category;
  132. $this->rule_status = $rules->rule_status;
  133. $this->create_time = $rules->create_time;
  134. $this->end_time = $rules->end_time;
  135. $this->update_time = $rules->update_time;
  136. $this->version = $rules->version;
  137. }
  138. /**
  139. * json_encode无法转化私有属性,需要使用jsonSerialize自定义转换私有的属性
  140. * @return array
  141. */
  142. public function jsonSerialize(): array
  143. {
  144. return [
  145. "id" => $this->id,
  146. "rule_name" => $this->rule_name,
  147. "rule_category" => $this->rule_category,
  148. "rule_content" => $this->rule_content,
  149. "rule_status" => $this->rule_status,
  150. "create_time" => $this->create_time,
  151. "end_time" => $this->end_time,
  152. "update_time" => $this->update_time,
  153. "version" => $this->version,
  154. ];
  155. }
  156. }