mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
去除Response类的result方法 改进Jump里面的result方法
This commit is contained in:
@@ -180,25 +180,6 @@ class Response
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回封装后的API数据到客户端
|
||||
* @access public
|
||||
* @param mixed $data 要返回的数据
|
||||
* @param integer $code 返回的code
|
||||
* @param string $msg 提示信息
|
||||
* @return mixed
|
||||
*/
|
||||
public function result($data, $code = 0, $msg = '')
|
||||
{
|
||||
$result = [
|
||||
'code' => $code,
|
||||
'msg' => $msg,
|
||||
'time' => $_SERVER['REQUEST_TIME'],
|
||||
'data' => $data,
|
||||
];
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置响应头
|
||||
* @access public
|
||||
|
||||
@@ -99,7 +99,14 @@ trait Jump
|
||||
*/
|
||||
protected function result($data, $code = 0, $msg = '', $type = '')
|
||||
{
|
||||
return Response::create([], $type)->result($data, $code, $msg);
|
||||
$result = [
|
||||
'code' => $code,
|
||||
'msg' => $msg,
|
||||
'time' => $_SERVER['REQUEST_TIME'],
|
||||
'data' => $data,
|
||||
];
|
||||
$type = $type ?: $this->getResponseType();
|
||||
return Response::create([], $type)->data($data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user