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.
34 lines
1.0 KiB
PHP
34 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Service;
|
|
|
|
use App\Exception\BusinessException;
|
|
use App\Helper\StringHelper;
|
|
use App\Model\RequestLog;
|
|
|
|
class RequestService extends AbstractService
|
|
{
|
|
public function getRequestLogByToken($token): RequestLog
|
|
{
|
|
$requestLog = RequestLog::where('request_token', $token)->first();
|
|
if (is_null($requestLog)) {
|
|
throw new BusinessException('token不存在');
|
|
}
|
|
return $requestLog;
|
|
}
|
|
|
|
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 = $params;
|
|
$requestLog->request_time = date('Y-m-d H:i:s');
|
|
$requestLog->save();
|
|
return $requestLog;
|
|
}
|
|
} |