user = $this->getUser(); $this->uuid = $this->user['id']; } /** * 获取用户数据 * @return array|void */ protected function getUser() { try { $user = UserService::instance(); $this->type = input('api', 'web'); if (empty($this->uuid)) { $token = input('token') ?: $this->request->header('token'); if (empty($token)) $this->error('接口认证令牌不能为空!'); [$state, $message, $this->uuid] = $user->checkUserToken($this->type, $token); if (empty($state)) $this->error($message); } return $user->get($this->type, $this->uuid); } catch (HttpResponseException $exception) { throw $exception; } catch (\Exception $exception) { $this->error($exception->getMessage()); } } }