|
...
|
...
|
@@ -46,29 +46,6 @@ class BaseController extends Controller |
|
|
|
$this->uid = $info['id'];
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 成功返回
|
|
|
|
* @param array $data
|
|
|
|
* @param int|string $code
|
|
|
|
* @param bool $objectData
|
|
|
|
* @return JsonResponse
|
|
|
|
* @author zbj
|
|
|
|
* @date 2023/4/12
|
|
|
|
*/
|
|
|
|
function success(array $data = [], $code = Code::SUCCESS, bool $objectData = false): JsonResponse
|
|
|
|
{
|
|
|
|
if ($objectData) {
|
|
|
|
$data = (object)$data;
|
|
|
|
}
|
|
|
|
$code = Code::fromValue($code);
|
|
|
|
$response = [
|
|
|
|
'code' => $code->value,
|
|
|
|
'data' => $data,
|
|
|
|
'msg' => $code->description,
|
|
|
|
];
|
|
|
|
return response()->json($response,200,$this->header);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name 参数过滤
|
|
|
|
* @return void
|
|
|
|
* @author :liyuhang
|
|
...
|
...
|
@@ -114,12 +91,12 @@ class BaseController extends Controller |
|
|
|
* @author :liyuhang
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
public function response($msg,$code = null,$data = [],$result_code = 200,$type = 'application/json'){
|
|
|
|
$code === null && $code = $result_code;
|
|
|
|
public function response($msg,string $code = Code::SUCCESS,$data = [],$result_code = 200,$type = 'application/json'){
|
|
|
|
$code = Code::fromValue($code);
|
|
|
|
$result = [
|
|
|
|
'msg' =>$msg,
|
|
|
|
'code'=>$code,
|
|
|
|
'data'=>$data
|
|
|
|
'msg' => $msg == null ? $msg : $code->description,
|
|
|
|
'code' => $code->value,
|
|
|
|
'data' => $data,
|
|
|
|
];
|
|
|
|
$this->header['Content-Type'] = $type;
|
|
|
|
$this->header['token'] = $this->token;
|
...
|
...
|
|