diff --git a/backend/docs/docs.go b/backend/docs/docs.go index 5c5258e..5aae9ee 100644 --- a/backend/docs/docs.go +++ b/backend/docs/docs.go @@ -2195,6 +2195,184 @@ const docTemplate = `{ } } } + }, + "/t/{tenantCode}/v1/public/contents": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "TenantPublic" + ], + "summary": "公开内容列表(已发布 + public)", + "parameters": [ + { + "type": "string", + "description": "Tenant Code", + "name": "tenantCode", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Keyword filters by title keyword (LIKE).", + "name": "keyword", + "in": "query" + }, + { + "type": "integer", + "description": "Limit is page size; only values in {10,20,50,100} are accepted (otherwise defaults to 10).", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "Page is 1-based page index; values \u003c= 0 are normalized to 1.", + "name": "page", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/requests.Pager" + }, + { + "type": "object", + "properties": { + "items": { + "$ref": "#/definitions/dto.ContentItem" + } + } + } + ] + } + } + } + } + }, + "/t/{tenantCode}/v1/public/contents/{contentID}": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "TenantPublic" + ], + "summary": "公开内容详情(已发布 + public)", + "parameters": [ + { + "type": "string", + "description": "Tenant Code", + "name": "tenantCode", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "ContentID", + "name": "contentID", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dto.ContentDetail" + } + } + } + } + }, + "/t/{tenantCode}/v1/public/contents/{contentID}/assets": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "TenantPublic" + ], + "summary": "获取公开正片资源(main role;免费/作者/已购)", + "parameters": [ + { + "type": "string", + "description": "Tenant Code", + "name": "tenantCode", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "ContentID", + "name": "contentID", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dto.ContentAssetsResponse" + } + } + } + } + }, + "/t/{tenantCode}/v1/public/contents/{contentID}/preview": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "TenantPublic" + ], + "summary": "获取公开试看资源(preview role)", + "parameters": [ + { + "type": "string", + "description": "Tenant Code", + "name": "tenantCode", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "ContentID", + "name": "contentID", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dto.ContentAssetsResponse" + } + } + } + } } }, "definitions": { diff --git a/backend/docs/swagger.json b/backend/docs/swagger.json index 17a2118..be85193 100644 --- a/backend/docs/swagger.json +++ b/backend/docs/swagger.json @@ -2189,6 +2189,184 @@ } } } + }, + "/t/{tenantCode}/v1/public/contents": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "TenantPublic" + ], + "summary": "公开内容列表(已发布 + public)", + "parameters": [ + { + "type": "string", + "description": "Tenant Code", + "name": "tenantCode", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Keyword filters by title keyword (LIKE).", + "name": "keyword", + "in": "query" + }, + { + "type": "integer", + "description": "Limit is page size; only values in {10,20,50,100} are accepted (otherwise defaults to 10).", + "name": "limit", + "in": "query" + }, + { + "type": "integer", + "description": "Page is 1-based page index; values \u003c= 0 are normalized to 1.", + "name": "page", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/requests.Pager" + }, + { + "type": "object", + "properties": { + "items": { + "$ref": "#/definitions/dto.ContentItem" + } + } + } + ] + } + } + } + } + }, + "/t/{tenantCode}/v1/public/contents/{contentID}": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "TenantPublic" + ], + "summary": "公开内容详情(已发布 + public)", + "parameters": [ + { + "type": "string", + "description": "Tenant Code", + "name": "tenantCode", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "ContentID", + "name": "contentID", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dto.ContentDetail" + } + } + } + } + }, + "/t/{tenantCode}/v1/public/contents/{contentID}/assets": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "TenantPublic" + ], + "summary": "获取公开正片资源(main role;免费/作者/已购)", + "parameters": [ + { + "type": "string", + "description": "Tenant Code", + "name": "tenantCode", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "ContentID", + "name": "contentID", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dto.ContentAssetsResponse" + } + } + } + } + }, + "/t/{tenantCode}/v1/public/contents/{contentID}/preview": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "TenantPublic" + ], + "summary": "获取公开试看资源(preview role)", + "parameters": [ + { + "type": "string", + "description": "Tenant Code", + "name": "tenantCode", + "in": "path", + "required": true + }, + { + "type": "integer", + "format": "int64", + "description": "ContentID", + "name": "contentID", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dto.ContentAssetsResponse" + } + } + } + } } }, "definitions": { diff --git a/backend/docs/swagger.yaml b/backend/docs/swagger.yaml index 37f370a..2755e01 100644 --- a/backend/docs/swagger.yaml +++ b/backend/docs/swagger.yaml @@ -2675,6 +2675,122 @@ paths: summary: 我的订单详情(当前租户) tags: - Tenant + /t/{tenantCode}/v1/public/contents: + get: + consumes: + - application/json + parameters: + - description: Tenant Code + in: path + name: tenantCode + required: true + type: string + - description: Keyword filters by title keyword (LIKE). + in: query + name: keyword + type: string + - description: Limit is page size; only values in {10,20,50,100} are accepted + (otherwise defaults to 10). + in: query + name: limit + type: integer + - description: Page is 1-based page index; values <= 0 are normalized to 1. + in: query + name: page + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/requests.Pager' + - properties: + items: + $ref: '#/definitions/dto.ContentItem' + type: object + summary: 公开内容列表(已发布 + public) + tags: + - TenantPublic + /t/{tenantCode}/v1/public/contents/{contentID}: + get: + consumes: + - application/json + parameters: + - description: Tenant Code + in: path + name: tenantCode + required: true + type: string + - description: ContentID + format: int64 + in: path + name: contentID + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/dto.ContentDetail' + summary: 公开内容详情(已发布 + public) + tags: + - TenantPublic + /t/{tenantCode}/v1/public/contents/{contentID}/assets: + get: + consumes: + - application/json + parameters: + - description: Tenant Code + in: path + name: tenantCode + required: true + type: string + - description: ContentID + format: int64 + in: path + name: contentID + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/dto.ContentAssetsResponse' + summary: 获取公开正片资源(main role;免费/作者/已购) + tags: + - TenantPublic + /t/{tenantCode}/v1/public/contents/{contentID}/preview: + get: + consumes: + - application/json + parameters: + - description: Tenant Code + in: path + name: tenantCode + required: true + type: string + - description: ContentID + format: int64 + in: path + name: contentID + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/dto.ContentAssetsResponse' + summary: 获取公开试看资源(preview role) + tags: + - TenantPublic securityDefinitions: BasicAuth: type: basic diff --git a/backend/tests/tenant_public.http b/backend/tests/tenant_public.http new file mode 100644 index 0000000..8423b31 --- /dev/null +++ b/backend/tests/tenant_public.http @@ -0,0 +1,36 @@ +@host = http://localhost:8080 +@tenantCode = 2s + +# NOTE: +# - tenant_public endpoints do NOT require tenant membership. +# - Auth is optional: provide a token to get accurate has_access for paid contents. +@token = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoyLCJpc3MiOiJ2MiIsImV4cCI6MTc2NjYzMzAyMSwibmJmIjoxNzY2MDI4MjExfQ.RjLVil6EnbPi4LMPyVBzR2vFaeXelypk5fKInsAzqc8 + +### Tenant Public - Contents list (published + public), guest +GET {{ host }}/t/{{ tenantCode }}/v1/public/contents?page=1&limit=10 +Content-Type: application/json + +### Tenant Public - Contents list (published + public), optional auth +GET {{ host }}/t/{{ tenantCode }}/v1/public/contents?page=1&limit=10 +Content-Type: application/json +Authorization: Bearer {{ token }} + +### Tenant Public - Content detail (published + public), guest +@contentID = 1 +GET {{ host }}/t/{{ tenantCode }}/v1/public/contents/{{ contentID }} +Content-Type: application/json + +### Tenant Public - Preview assets (role=preview), guest +GET {{ host }}/t/{{ tenantCode }}/v1/public/contents/{{ contentID }}/preview +Content-Type: application/json + +### Tenant Public - Main assets (role=main), guest +# Rule confirmed: public + price=0 => guest can access main assets. +GET {{ host }}/t/{{ tenantCode }}/v1/public/contents/{{ contentID }}/assets +Content-Type: application/json + +### Tenant Public - Main assets (role=main), optional auth (paid content requires purchase/owner) +GET {{ host }}/t/{{ tenantCode }}/v1/public/contents/{{ contentID }}/assets +Content-Type: application/json +Authorization: Bearer {{ token }} +