封装返回值

// 这是系统自动生成的公共文件


if(!function_exists('responses')){
function responses($code,$msg,$data):\think\response\Json
{
return json([
'code'=>$code,
'msg'=>$msg,
'data'=>$data
]);
}
}

if(!function_exists('success')){
function success($data,$code=200,$msg=""):\think\response\Json
{
return responses($code,$msg,$data);
}
}
//响应失败
if(!function_exists('fail')){
function fail($msg,$code=500,$data=[]):\think\response\Json
{
return responses($code,$msg,$data);
}
}
posted @ 2021-12-19 23:35  南瓜不能吃  阅读(27)  评论(0)    收藏  举报