作者 lyh

gx

@@ -102,21 +102,12 @@ class BaseController extends Controller @@ -102,21 +102,12 @@ class BaseController extends Controller
102 */ 102 */
103 public function response($msg = null,string $code = Code::SUCCESS,$data = [],$result_code = 200,$type = 'application/json'): JsonResponse 103 public function response($msg = null,string $code = Code::SUCCESS,$data = [],$result_code = 200,$type = 'application/json'): JsonResponse
104 { 104 {
105 - try {  
106 - $code = Code::fromValue($code);  
107 - $result = [  
108 - 'msg' => $msg == ' ' ? $code->description : $msg,  
109 - 'code' => $code->value,  
110 - 'data' => $this->_extents($data),  
111 - ];  
112 - }catch (\Throwable $e){  
113 - $result = [  
114 - 'msg' => $msg,  
115 - 'code' => $code,  
116 - 'data' => $this->_extents($data),  
117 - ];  
118 - }  
119 - 105 + $code = Code::fromValue($code);
  106 + $result = [
  107 + 'msg' => $msg == ' ' ? $code->description : $msg,
  108 + 'code' => $code->value,
  109 + 'data' => $this->_extents($data),
  110 + ];
120 $this->header['Content-Type'] = $type; 111 $this->header['Content-Type'] = $type;
121 $this->header['token'] = $this->token; 112 $this->header['token'] = $this->token;
122 $response = response($result,$result_code,$this->header);; 113 $response = response($result,$result_code,$this->header);;