Commit af3d942a by 叶明星

修改返回方法

parent e0c14130
......@@ -32,7 +32,7 @@ class Controller extends BaseController
}else{
$data['data'] = $dataArr;
}
return json_encode($data);
return response()->json($data);
}
/**
......
......@@ -18,46 +18,6 @@ class ServicesController extends Controller
return $this->$id($request, $id);
}
public function apiReturn($Errcode = 0, $level = 1 , $dataArr = '') {
//生成错误码
$Errcode = $this->Errcode($Errcode , $level);
//获取错误描述
$ErrMsg = config('errmsg.cn.'.$Errcode);
//上报错误
$data=['errcode'=>$Errcode, 'errmsg'=>$ErrMsg];
//非正常返回码,上报
if(($data['errcode'] < 10000 || $data['errcode'] >= 50000) && $data['errcode'] !==0 ){
try{
ErrorLog($Errcode,$ErrMsg);
}catch (\Exception $e){
Log::info($e);
}
}
if(!empty($dataArr) && is_array($dataArr)){
foreach ($dataArr as $k=>$v){
$data['data'][$k]=$v;
}
}else{
$data['data'] = $dataArr;
}
return json_encode($data);
}
/**
* @param int $code 错误码
* @param int $level 错误级别 1普通错误 5需关注错误 9致命错误,急需解决
* @return int
*/
protected function Errcode( $code = 0,$level=1){
if($code === 0) return 0;
$SystemCode=config('website.SystemCode');
return errCode($code,$level,$SystemCode);
}
/**
* 获取仓库信息
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment