123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 |
- <?php
- namespace common\util;
- use JsonSerializable;
- /**
- * Class DictionaryObj
- * @package common\util
- * @property int $id
- * @property int $pid
- * @property string $name
- * @property int $status
- * @property array $children
- * @property int $multiple
- * @property array $derive
- * @property int $sort
- */
- class DictionaryObj implements JsonSerializable
- {
- /**
- * ID
- */
- private $id;
- /**
- * 父ID
- */
- private $pid;
- /**
- * 名称
- */
- private $name;
- /**
- * 状态
- */
- private $status;
- /**
- * 节点属性
- */
- private $children = [];
- private $multiple;
- private $derive = [];
- private $has_children = [];
- private $can_change = [];
- private $can_children;
- private $can_multiple;
- private $sort;
- /**
- * @return mixed
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * @param mixed $id
- */
- public function setId($id)
- {
- $this->id = $id;
- }
- /**
- * @return mixed
- */
- public function getPid(): int
- {
- return $this->pid;
- }
- /**
- * @param mixed $pid
- */
- public function setPid($pid)
- {
- $this->pid = $pid;
- }
- /**
- * @return mixed
- */
- public function getName(): string
- {
- return $this->name;
- }
- /**
- * @param mixed $name
- */
- public function setName($name)
- {
- $this->name = $name;
- }
- /**
- * @return mixed
- */
- public function getStatus(): int
- {
- return $this->status;
- }
- /**
- * @param mixed $status
- */
- public function setStatus($status)
- {
- $this->status = $status;
- }
- /**
- * @return array
- */
- public function getChildren(): array
- {
- return $this->children;
- }
- /**
- * @param array $children
- */
- public function setChildren(array $children)
- {
- $this->children = $children;
- }
- /**
- * @param DictionaryObj $children
- */
- public function addChildrenToTop(DictionaryObj $children)
- {
- array_unshift($this->children, $children);
- }
- /**
- * @param DictionaryObj $children
- */
- public function addChildrenToBottom(DictionaryObj $children)
- {
- $this->children[] = $children;
- }
- /**
- * @return mixed
- */
- public function getMultiple(): int
- {
- return $this->multiple;
- }
- /**
- * @param mixed $multiple
- */
- public function setMultiple($multiple)
- {
- $this->multiple = $multiple;
- }
- /**
- * @return array
- */
- public function getDerive(): array
- {
- return $this->derive;
- }
- /**
- * @param DeriveObj $derive
- */
- public function addDeriveToTop(DeriveObj $derive)
- {
- array_unshift($this->derive, $derive);
- }
- /**
- * @param DeriveObj $derive
- */
- public function addDeriveToBottom(DeriveObj $derive)
- {
- $this->derive[] = $derive;
- }
- /**
- * @param array $derive
- */
- public function setDerive(array $derive)
- {
- $this->derive = $derive;
- }
- public function __construct($id, $pid, $name, $status, $multiple, $has_children, $can_change, $can_children, $can_multiple,$sort)
- {
- $this->id = $id;
- $this->pid = $pid;
- $this->name = $name;
- $this->status = $status;
- $this->multiple = $multiple;
- $this->has_children = $has_children;
- $this->can_change = $can_change;
- $this->can_children = $can_children;
- $this->can_multiple = $can_multiple;
- $this->sort = $sort;
- }
- /**
- * json_encode无法转化私有属性,需要使用jsonSerialize自定义转换私有的属性
- * @return array
- */
- public function jsonSerialize(): array
- {
- return [
- "id" => $this->id,
- "pid" => $this->pid,
- "name" => $this->name,
- "status" => $this->status,
- "multiple" => $this->multiple,
- "children" => $this->children,
- "derive" => $this->derive,
- "has_children" => $this->has_children,
- "can_change" => $this->can_change,
- "can_children" => $this->can_children,
- "can_multiple" => $this->can_multiple,
- "sort" => $this->sort,
- ];
- }
- }
|