This commit is contained in:
gaofeng
2026-09-02 15:25:34 +08:00
parent f79f72fd68
commit beddee1b1a
2 changed files with 3 additions and 3 deletions

View File

@@ -21,7 +21,7 @@ final class VisaApplicationService
public function endpoint(string $userUrl, string $action): string
{
if (!in_array($action, self::ACTIONS, true)) return '';
$endpoint = preg_replace('#/users/[^/?]+(?:\?.*)?$#i', '/visa_application/' . $action, rtrim(trim($userUrl), '/'));
$endpoint = preg_replace('#/users/[^/?]+(?:\?.*)?$#i', '/visa_service/' . $action, rtrim(trim($userUrl), '/'));
return is_string($endpoint) && $endpoint !== rtrim(trim($userUrl), '/') ? $endpoint : '';
}
public function dataSource(string $type, array $filters): array

View File

@@ -9,8 +9,8 @@ require dirname(__DIR__) . '/app/miniapi/service/VisaApplication/VisaApplication
use app\miniapi\service\VisaApplication\VisaApplicationService;
$service = new VisaApplicationService();
if ($service->endpoint('https://user.example.com/users/list', 'start') !== 'https://user.example.com/visa_application/start') throw new RuntimeException('endpoint construction failed');
if ($service->endpoint('https://user.example.com/users/list', 'dataSource') !== 'https://user.example.com/visa_application/dataSource') throw new RuntimeException('data source forwarding endpoint failed');
if ($service->endpoint('https://user.example.com/users/list', 'start') !== 'https://user.example.com/visa_service/start') throw new RuntimeException('endpoint construction failed');
if ($service->endpoint('https://user.example.com/users/list', 'dataSource') !== 'https://user.example.com/visa_service/dataSource') throw new RuntimeException('data source forwarding endpoint failed');
if ($service->endpoint('https://user.example.com/users/list', 'invalid') !== '') throw new RuntimeException('action allowlist failed');
$payload = $service->payload(9, ['order_source' => 'jnwxmini']);
if (isset($payload['user_id']) || (json_decode((string)($payload['user_token'] ?? ''), true) !== ['purpose' => 'visa_api', 'user_id' => 9, 'order_source' => 'jnwxmini'])) throw new RuntimeException('trusted token payload failed');