输出调试代码
This commit is contained in:
@@ -16,6 +16,7 @@ trait ApiResponse
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* [$statusCode description]
|
* [$statusCode description]
|
||||||
|
*
|
||||||
* @var [type]
|
* @var [type]
|
||||||
*/
|
*/
|
||||||
protected $statusCode = FoundationResponse::HTTP_OK;
|
protected $statusCode = FoundationResponse::HTTP_OK;
|
||||||
@@ -24,7 +25,8 @@ trait ApiResponse
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 加密
|
* 加密
|
||||||
* @param <type> $value
|
*
|
||||||
|
* @param <type> $value
|
||||||
* @return <type>
|
* @return <type>
|
||||||
*/
|
*/
|
||||||
public function keyasc($value)
|
public function keyasc($value)
|
||||||
@@ -40,7 +42,8 @@ trait ApiResponse
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 解密
|
* 解密
|
||||||
* @param <type> $value
|
*
|
||||||
|
* @param <type> $value
|
||||||
* @return <type>
|
* @return <type>
|
||||||
*/
|
*/
|
||||||
public function keydesc($value)
|
public function keydesc($value)
|
||||||
@@ -61,18 +64,18 @@ trait ApiResponse
|
|||||||
$data = $request->data ?? false;
|
$data = $request->data ?? false;
|
||||||
$addcode = $request->addcode ?? false;
|
$addcode = $request->addcode ?? false;
|
||||||
$sign = $request->sign ?? false;
|
$sign = $request->sign ?? false;
|
||||||
if (!$server_id) {
|
if (! $server_id) {
|
||||||
return '参数server_id不能为空';
|
return '参数server_id不能为空';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$key) {
|
if (! $key) {
|
||||||
return '参数key不能为空';
|
return '参数key不能为空';
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->user = User::where('server_id', $server_id)
|
$this->user = User::where('server_id', $server_id)
|
||||||
->where('server_key', $key)->first();
|
->where('server_key', $key)->first();
|
||||||
|
|
||||||
if (!$this->user) {
|
if (! $this->user) {
|
||||||
return '参数server_id与key不匹配';
|
return '参数server_id与key不匹配';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,15 +83,15 @@ trait ApiResponse
|
|||||||
return '渠道商状态不正确';
|
return '渠道商状态不正确';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$sign) {
|
if (! $sign) {
|
||||||
return '参数sign不能为空';
|
return '参数sign不能为空';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$data) {
|
if (! $data) {
|
||||||
return '参数data不能为空';
|
return '参数data不能为空';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$addcode) {
|
if (! $addcode) {
|
||||||
return '参数addcode不能为空';
|
return '参数addcode不能为空';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +103,9 @@ trait ApiResponse
|
|||||||
}
|
}
|
||||||
$keydesc = $this->keydesc($data);
|
$keydesc = $this->keydesc($data);
|
||||||
$keydescArr = json_decode($this->keydesc($data), true);
|
$keydescArr = json_decode($this->keydesc($data), true);
|
||||||
if (empty($keydescArr) && !empty($keydesc)) {
|
if (empty($keydescArr) && ! empty($keydesc)) {
|
||||||
|
info(json_encode($keydescArr));
|
||||||
|
info(json_encode($keydesc));
|
||||||
return '传递的json数据不对';
|
return '传递的json数据不对';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +114,7 @@ trait ApiResponse
|
|||||||
|
|
||||||
public function keysign($jsonData = '', $addcode = '')
|
public function keysign($jsonData = '', $addcode = '')
|
||||||
{
|
{
|
||||||
$signStr = 'data=' . $jsonData . '&addcode=' . $addcode . '&key=' . $this->user->server_key;
|
$signStr = 'data='.$jsonData.'&addcode='.$addcode.'&key='.$this->user->server_key;
|
||||||
$sign = hash_hmac('sha256', $signStr, $this->user->server_key);
|
$sign = hash_hmac('sha256', $signStr, $this->user->server_key);
|
||||||
|
|
||||||
return $sign;
|
return $sign;
|
||||||
@@ -117,10 +122,11 @@ trait ApiResponse
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 成功的返回
|
* 成功的返回
|
||||||
|
*
|
||||||
* @Author :<C.Jason>
|
* @Author :<C.Jason>
|
||||||
* @Date :2018-05-22
|
* @Date :2018-05-22
|
||||||
* @param [type] $data [description]
|
* @param [type] $data [description]
|
||||||
* @param string $log
|
* @param string $log
|
||||||
* @return [type] [description]
|
* @return [type] [description]
|
||||||
*/
|
*/
|
||||||
public function success($data, $log = '')
|
public function success($data, $log = '')
|
||||||
@@ -138,7 +144,7 @@ trait ApiResponse
|
|||||||
];
|
];
|
||||||
|
|
||||||
if ($log) {
|
if ($log) {
|
||||||
if (!is_array($data)) {
|
if (! is_array($data)) {
|
||||||
$data = [$data];
|
$data = [$data];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,7 +172,7 @@ trait ApiResponse
|
|||||||
{
|
{
|
||||||
$rt = microtime(true) - LARAVEL_START;
|
$rt = microtime(true) - LARAVEL_START;
|
||||||
|
|
||||||
$header = array_merge($header, ['rt' => round($rt * 1000, 2) . 'ms', 'qps' => round(1 / $rt, 1)]);
|
$header = array_merge($header, ['rt' => round($rt * 1000, 2).'ms', 'qps' => round(1 / $rt, 1)]);
|
||||||
|
|
||||||
return Response::json($data, $code, $header);
|
return Response::json($data, $code, $header);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user