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