5 changed files with 46 additions and 94 deletions
-
61app/Commons/LanzuRequest.php
-
15app/Middleware/Auth/ApiMiddleware.php
-
54app/Middleware/CorsMiddleware.php
-
5app/Service/v3/Implementations/CouponRecService.php
-
5app/Service/v3/Implementations/GoodsActivityService.php
@ -1,61 +0,0 @@ |
|||
<?php |
|||
|
|||
declare(strict_types=1); |
|||
|
|||
namespace App\Commons; |
|||
|
|||
use Hyperf\HttpServer\Request; |
|||
use Hyperf\Utils\Context; |
|||
|
|||
class LanzuRequest extends Request |
|||
{ |
|||
// protected function getInputData(): array
|
|||
// {
|
|||
|
|||
// return $this->storeParsedData(function () {
|
|||
// $request = $this->getRequest();
|
|||
// if (is_array($request->getParsedBody())) {
|
|||
// $data = $request->getParsedBody();
|
|||
// } else {
|
|||
// $data = [];
|
|||
// }
|
|||
|
|||
// return array_merge($data, $request->getQueryParams());
|
|||
// });
|
|||
// }
|
|||
|
|||
protected function storeParsedData(callable $callback) |
|||
{ |
|||
if (! Context::has($this->contextkeys['parsedData'])) { |
|||
return Context::set($this->contextkeys['parsedData'], call($callback)); |
|||
} |
|||
|
|||
// var_dump(Context::get($this->contextkeys['parsedData']));
|
|||
|
|||
$preDatas = Context::get($this->contextkeys['parsedData']); |
|||
|
|||
if(isset($preDatas['market_id'])){ |
|||
if($preDatas['market_id']==-1){ |
|||
$preDatas['market_id'] = 0; |
|||
unset($preDatas['sign']); |
|||
$sign = $this->signature($preDatas); |
|||
$preDatas['sign'] = $sign; |
|||
Context::set($this->contextkeys['parsedData'],$preDatas); |
|||
} |
|||
} |
|||
|
|||
return Context::get($this->contextkeys['parsedData']); |
|||
} |
|||
|
|||
private function signature($params) |
|||
{ |
|||
ksort($params); |
|||
|
|||
$http_query = []; |
|||
foreach ($params as $key => $value) { |
|||
$http_query[] = $key.'='.$value; |
|||
} |
|||
|
|||
return sha1(md5(implode('&', $http_query)).config('auth.api.sign.secret_key')); |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue