mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
[更新]修改接口返回参数
This commit is contained in:
parent
1756305e42
commit
c4606f5037
@ -42,22 +42,24 @@ class BasicApi
|
||||
|
||||
/**
|
||||
* 返回成功的操作
|
||||
* @param string $msg 消息内容
|
||||
* @param mixed $msg 消息内容
|
||||
* @param array $data 返回数据
|
||||
* @param integer $code 返回代码
|
||||
*/
|
||||
protected function success($msg, $data = [])
|
||||
protected function success($msg, $data = [], $code = 1)
|
||||
{
|
||||
ToolsService::success($msg, $data);
|
||||
ToolsService::success($msg, $data, $code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回失败的请求
|
||||
* @param string $msg 消息内容
|
||||
* @param mixed $msg 消息内容
|
||||
* @param array $data 返回数据
|
||||
* @param integer $code 返回代码
|
||||
*/
|
||||
protected function error($msg, $data = [])
|
||||
protected function error($msg, $data = [], $code = 0)
|
||||
{
|
||||
ToolsService::error($msg, $data);
|
||||
ToolsService::error($msg, $data, $code);
|
||||
}
|
||||
|
||||
}
|
@ -70,23 +70,25 @@ class ToolsService
|
||||
|
||||
/**
|
||||
* 返回成功的操作
|
||||
* @param string $msg 消息内容
|
||||
* @param mixed $msg 消息内容
|
||||
* @param array $data 返回数据
|
||||
* @param integer $code 返回代码
|
||||
*/
|
||||
public static function success($msg, $data = [])
|
||||
public static function success($msg, $data = [], $code = 1)
|
||||
{
|
||||
$result = ['code' => 1, 'msg' => $msg, 'data' => $data, 'token' => encode(session_name() . '=' . session_id())];
|
||||
$result = ['code' => $code, 'msg' => $msg, 'data' => $data, 'token' => encode(session_name() . '=' . session_id())];
|
||||
throw new HttpResponseException(Response::create($result, 'json', 200, self::corsRequestHander()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回失败的请求
|
||||
* @param string $msg 消息内容
|
||||
* @param mixed $msg 消息内容
|
||||
* @param array $data 返回数据
|
||||
* @param integer $code 返回代码
|
||||
*/
|
||||
public static function error($msg, $data = [])
|
||||
public static function error($msg, $data = [], $code = 0)
|
||||
{
|
||||
$result = ['code' => 0, 'msg' => $msg, 'data' => $data, 'token' => encode(session_name() . '=' . session_id())];
|
||||
$result = ['code' => $code, 'msg' => $msg, 'data' => $data, 'token' => encode(session_name() . '=' . session_id())];
|
||||
throw new HttpResponseException(Response::create($result, 'json', 200, self::corsRequestHander()));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user