From f93caefcb2d422238621161f25bf576317252702 Mon Sep 17 00:00:00 2001 From: Rogee Date: Thu, 18 Dec 2025 11:28:55 +0800 Subject: [PATCH] feat: add http client --- backend/tests/tenant.http | 81 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 backend/tests/tenant.http diff --git a/backend/tests/tenant.http b/backend/tests/tenant.http new file mode 100644 index 0000000..32d5513 --- /dev/null +++ b/backend/tests/tenant.http @@ -0,0 +1,81 @@ +@host = http://localhost:8080 +@tenantCode = 2s + +# NOTE: +# - tenant module requires JWT auth + tenant membership. +# - Get a token via `tests/super.http` (`/super/v1/auth/token`) then paste it below. +@token = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoyLCJpc3MiOiJ2MiIsImV4cCI6MTc2NjYzMzAyMSwibmJmIjoxNzY2MDI4MjExfQ.RjLVil6EnbPi4LMPyVBzR2vFaeXelypk5fKInsAzqc8 + + +### Tenant - Me (resolved tenant/user/tenant_user) +GET {{ host }}/t/{{ tenantCode }}/v1/me +Content-Type: application/json +Authorization: Bearer {{ token }} + +### Tenant - Contents list (published) +GET {{ host }}/t/{{ tenantCode }}/v1/contents?page=1&limit=10 +Content-Type: application/json +Authorization: Bearer {{ token }} + +### Tenant - Content detail (visibility + access check) +@contentID = 1 +GET {{ host }}/t/{{ tenantCode }}/v1/contents/{{ contentID }} +Content-Type: application/json +Authorization: Bearer {{ token }} + +### Tenant - Preview assets (role=preview) +GET {{ host }}/t/{{ tenantCode }}/v1/contents/{{ contentID }}/preview +Content-Type: application/json +Authorization: Bearer {{ token }} + +### Tenant - Main assets (role=main, requires access unless free/owner) +GET {{ host }}/t/{{ tenantCode }}/v1/contents/{{ contentID }}/assets +Content-Type: application/json +Authorization: Bearer {{ token }} + +### Tenant Admin - Create content draft +POST {{ host }}/t/{{ tenantCode }}/v1/admin/contents +Content-Type: application/json +Authorization: Bearer {{ token }} + +{ + "title": "示例内容", + "description": "这是一个内容草稿,用于联调", + "visibility": "tenant_only", + "preview_seconds": 60 +} + +### Tenant Admin - Update content (publish/unpublish/title/description/preview_seconds) +PATCH {{ host }}/t/{{ tenantCode }}/v1/admin/contents/{{ contentID }} +Content-Type: application/json +Authorization: Bearer {{ token }} + +{ + "title": "示例内容(已更新)", + "status": "published" +} + +### Tenant Admin - Upsert content price/discount +PUT {{ host }}/t/{{ tenantCode }}/v1/admin/contents/{{ contentID }}/price +Content-Type: application/json +Authorization: Bearer {{ token }} + +{ + "currency": "CNY", + "price_amount": 990, + "discount_type": "none", + "discount_value": 0 +} + +### Tenant Admin - Attach asset to content (main/cover/preview) +@assetID = 1 +POST {{ host }}/t/{{ tenantCode }}/v1/admin/contents/{{ contentID }}/assets +Content-Type: application/json +Authorization: Bearer {{ token }} + +{ + "asset_id": {{ assetID }}, + "role": "main", + "sort": 0 +} +