This commit is contained in:
toom1996
2025-07-17 11:37:15 +08:00
parent 9a76ce372b
commit f0eed20b0a
5 changed files with 37 additions and 6 deletions

View File

@ -10,6 +10,7 @@ class RpcResponse
public array $meta = [];
public string $title = '';
public array $pageModule = [];
public array $extra = [];
public function setData(array $data)
@ -18,6 +19,12 @@ class RpcResponse
return $this;
}
public function setExtra($extraKey = '', $value = '')
{
$this->extra[$extraKey] = $value;
return $this;
}
public function setCode(int $code)
{
$this->code = $code;
@ -32,10 +39,17 @@ class RpcResponse
public function send()
{
return [
$resp = [
'code' => $this->code,
'msg' => $this->msg,
'data' => $this->data,
];
if ($this->extra) {
foreach ($this->extra as $key => $item) {
$resp[$key] = $item;
}
}
return $resp;
}
}