diff --git a/src/AuthorServerClient.php b/src/AuthorServerClient.php index 53990d6..87f23fc 100644 --- a/src/AuthorServerClient.php +++ b/src/AuthorServerClient.php @@ -162,7 +162,7 @@ class AuthorServerClient return new BizResponse(); } $data = json_decode($content, true); - return new BizResponse($data['code'] ?? 0, $data['message'] ?? '', $data['data'] ?? []); + return new BizResponse($data['code'] ?? 0, $data['message'] ?? '', $data['data'] ?? [], $data['err'] ?? ''); } catch (ClientException $e) { $body = $e->getResponse()->getBody()->getContents(); diff --git a/src/response/BizResponse.php b/src/response/BizResponse.php index fa6449e..3bbcc90 100644 --- a/src/response/BizResponse.php +++ b/src/response/BizResponse.php @@ -6,19 +6,22 @@ class BizResponse { private int $code; private string $message; - private $data; + private mixed $data; + private string $errCode; /** * @param int $code * @param string $message - * @param $data + * @param array $data + * @param string $errCode */ - public function __construct(int $code = -1, string $message = '', $data = []) + public function __construct(int $code = -1, string $message = '', mixed $data = [], string $errCode = '') { $this->code = $code; $this->message = $message; $this->data = $data; + $this->errCode = $errCode; } public function isSuccess(): bool @@ -49,7 +52,7 @@ class BizResponse /** * @return mixed */ - public function getData() + public function getData(): mixed { return $this->data; } @@ -62,5 +65,15 @@ class BizResponse $this->data = $data; } + public function getErrCode(): string + { + return $this->errCode; + } + + public function setErrCode(string $errCode): void + { + $this->errCode = $errCode; + } + } \ No newline at end of file