| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- <?php
- namespace app\entity\admin\request\user;
- use app\entity\request\RequestCommonEntity;
- /**
- * 添加0号线用户请求参数
- */
- class ZeroUserRequestEntity extends RequestCommonEntity
- {
- // id
- public $id;
- // 万能验证码
- public $customCode;
- // 状态
- public $status;
- // 团队昵称
- public $teamName;
- // 团队长uid
- public $teamUid;
- // 是否移除团队
- public $isRemove;
- // 获取id
- public function getId()
- {
- return $this->id;
- }
- // 设置id
- public function setId($id)
- {
- $this->id = $id;
- return $this;
- }
- // 获取万能验证码
- public function getCustomCode()
- {
- return $this->customCode;
- }
- // 设置万能验证码
- public function setCustomCode($customCode)
- {
- $this->customCode = $customCode ?? null;
- return $this;
- }
- // 获取团队昵称
- public function getStatus()
- {
- return $this->status;
- }
- public function setStatus($status)
- {
- $this->status = $status;
- return $this;
- }
- // 获取团队昵称
- public function getTeamName()
- {
- return $this->teamName ?? '';
- }
- public function setTeamName($teamName): ZeroUserRequestEntity
- {
- $this->teamName = $teamName;
- return $this;
- }
- // 获取团队长uid
- public function getTeamUid()
- {
- return $this->teamUid;
- }
- public function setTeamUid($teamUid): ZeroUserRequestEntity
- {
- $this->teamUid = $teamUid;
- return $this;
- }
- // 获取是否移除
- public function getIsRemove()
- {
- return $this->isRemove;
- }
- public function setIsRemove($isRemove): ZeroUserRequestEntity
- {
- $this->isRemove = $isRemove;
- return $this;
- }
- /**
- * 将请求参数转换为数组格式
- * 用于数据库操作或API传输
- * 动态获取当前类的所有公共属性,使用下划线分割的键名
- *
- * @return array
- */
- public function getArray(): array
- {
- $result = [];
- $reflection = new \ReflectionClass($this);
- $properties = $reflection->getProperties(\ReflectionProperty::IS_PUBLIC);
-
- foreach ($properties as $property) {
- $propertyName = $property->getName();
- // 跳过继承的属性
- if ($property->getDeclaringClass()->getName() !== self::class) {
- continue;
- }
-
- // 将驼峰命名转换为下划线命名
- $key = strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $propertyName));
-
- // 获取对应的getter方法名
- $getterMethod = 'get' . ucfirst($propertyName);
-
- if (method_exists($this, $getterMethod)) {
- $result[$key] = $this->$getterMethod();
- } else {
- // 如果没有对应的getter方法,直接获取属性值
- $result[$key] = $this->$propertyName;
- }
- }
-
- return $result;
- }
- }
|