You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace App\Service;
|
|
|
|
|
|
|
|
use App\Helper\StringHelper;
|
|
|
|
use App\Model\RequestLog;
|
|
|
|
|
|
|
|
class RequestService extends AbstractService
|
|
|
|
{
|
|
|
|
public function getRequestLogByToken($token): ?RequestLog
|
|
|
|
{
|
|
|
|
return RequestLog::where('request_token', $token)->first();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function createRequestLog($requestUri, $params): RequestLog
|
|
|
|
{
|
|
|
|
$requestLog = new RequestLog();
|
|
|
|
$requestLog->app_id = $params['app_id'] ?? 0;
|
|
|
|
$requestLog->request_id = StringHelper::generateOrderNo(StringHelper::ORDER_NO_TYPE_REQUEST_ID);
|
|
|
|
$requestLog->request_token = $requestLog->generateToken();
|
|
|
|
$requestLog->request_uri = $requestUri;
|
|
|
|
$requestLog->request_data = json_encode($params, JSON_UNESCAPED_UNICODE);
|
|
|
|
$requestLog->request_time = date('Y-m-d H:i:s');
|
|
|
|
$requestLog->save();
|
|
|
|
return $requestLog;
|
|
|
|
}
|
|
|
|
}
|