feat: 添加公开内容相关API接口及测试用例

This commit is contained in:
2025-12-22 16:33:35 +08:00
parent 39454458f1
commit 7eb7b14557
4 changed files with 508 additions and 0 deletions

View File

@@ -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": { "definitions": {

View File

@@ -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": { "definitions": {

View File

@@ -2675,6 +2675,122 @@ paths:
summary: 我的订单详情(当前租户) summary: 我的订单详情(当前租户)
tags: tags:
- Tenant - 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: securityDefinitions:
BasicAuth: BasicAuth:
type: basic type: basic

View File

@@ -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 }}