| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- /**
- * 单个用户信息返回数据封装.
- *
- * @author nj <nj@gmail.com>
- * @date 2020-01-16 17:57:50
- */
- declare(strict_types=1);
- namespace Modules\Api\Responses;
- use App\Contracts\Responsable;
- class UserInfoResponse implements Responsable
- {
- /**
- * 录入的数据.
- *
- * @var mixed
- */
- private $data = null;
- /**
- * 附加条件参数.
- *
- * @var array
- */
- private $params = [];
- public function __construct($data = null, $params = [])
- {
- $this->data = $data;
- $this->params = $params;
- }
- public function toResponse(
- $request = null
- ) {
- $res = [];
- if (!empty($this->data->code)) {
- $res = [
- 'user_id' => $this->data->code,
- 'nick' => $this->data->nick,
- 'avatar' => $this->data->avatar,
- ];
- return json_success($res);
- } else {
- return json_fail('信息有误');
- }
- }
- }
|