RulesWithContentObj.php 4.3 KB

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