Files
quyun-v2/backend/tests/tenant.http
Rogee 1da84f2af3 feat: add TenantLedger model and query generation
- Introduced TenantLedger model with fields for managing tenant transactions, including ID, TenantID, UserID, OrderID, transaction Type, Amount, and balance details.
- Implemented CRUD operations for TenantLedger with methods for Create, Update, Delete, and Reload.
- Generated query methods for TenantLedger to facilitate database interactions, including filtering, pagination, and aggregation functions.
- Established relationships with Order model for foreign key references.
2025-12-18 13:12:26 +08:00

122 lines
3.5 KiB
HTTP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@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 - Purchase content (tenant balance)
POST {{ host }}/t/{{ tenantCode }}/v1/contents/{{ contentID }}/purchase
Content-Type: application/json
Authorization: Bearer {{ token }}
{
"idempotency_key": "purchase-{{ contentID }}-001"
}
### Tenant - My orders list
GET {{ host }}/t/{{ tenantCode }}/v1/orders?page=1&limit=10
Content-Type: application/json
Authorization: Bearer {{ token }}
### Tenant - My order detail
GET {{ host }}/t/{{ tenantCode }}/v1/orders/{{ orderID }}
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
}
### Tenant Admin - Orders list
GET {{ host }}/t/{{ tenantCode }}/v1/admin/orders?page=1&limit=10
Content-Type: application/json
Authorization: Bearer {{ token }}
### Tenant Admin - Order detail
@orderID = 1
GET {{ host }}/t/{{ tenantCode }}/v1/admin/orders/{{ orderID }}
Content-Type: application/json
Authorization: Bearer {{ token }}
### Tenant Admin - Refund order (default window paid_at + 24h)
POST {{ host }}/t/{{ tenantCode }}/v1/admin/orders/{{ orderID }}/refund
Content-Type: application/json
Authorization: Bearer {{ token }}
{
"force": false,
"reason": "退",
"idempotency_key": "refund-{{ orderID }}-001"
}