fix: 修复Swagger文档生成和API路径配置

- 修复generate-swagger-json.ts中API前缀配置,与main.ts保持一致
- 修复content-moderation.controller.ts中重复的API前缀
- 更新Swagger配置从环境变量获取服务地址
- 重新生成API文档确保路径正确
This commit is contained in:
imeepos
2025-09-05 18:30:50 +08:00
parent 37f4d8e7c6
commit 8ea6e4ed61
6 changed files with 1268 additions and 157 deletions

View File

@@ -1,56 +1,7 @@
{
"openapi": "3.0.0",
"paths": {
"/api/v1/templates": {
"get": {
"operationId": "AppController_getTemplates",
"parameters": [],
"responses": {
"200": {
"description": ""
}
},
"tags": [
"App"
]
},
"post": {
"operationId": "AppController_executeTemplate",
"parameters": [],
"responses": {
"201": {
"description": ""
}
},
"tags": [
"App"
]
}
},
"/api/v1/templates/{templateCode}": {
"get": {
"operationId": "AppController_getTemplate",
"parameters": [
{
"name": "templateCode",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": ""
}
},
"tags": [
"App"
]
}
},
"/api/v1/templates/callback": {
"/api/v1/callback": {
"post": {
"operationId": "AppController_callback",
"parameters": [],
@@ -64,7 +15,7 @@
]
}
},
"/templates/{templateId}/execute": {
"/api/v1/templates/{templateId}/execute": {
"post": {
"description": "根据模板ID执行AI生成任务支持图片和视频生成",
"operationId": "TemplateController_executeTemplateById",
@@ -142,9 +93,9 @@
]
}
},
"/templates/code/{code}/execute": {
"/api/v1/templates/code/{code}/execute": {
"post": {
"description": "根据模板代码执行AI生成任务支持图片和视频生成",
"description": "根据模板代码执行AI生成任务支持图片和视频生成。执行前会进行图片内容审核。",
"operationId": "TemplateController_executeTemplateByCode",
"parameters": [
{
@@ -199,6 +150,34 @@
}
}
},
"403": {
"description": "图片审核未通过",
"content": {
"application/json": {
"schema": {
"example": {
"code": 403,
"message": "图片审核未通过: 包含不当内容",
"data": null
}
}
}
}
},
"429": {
"description": "任务数量限制",
"content": {
"application/json": {
"schema": {
"example": {
"code": 429,
"message": "当前账号有3个任务正在进行中且距开始时间不足5分钟请稍后再试",
"data": null
}
}
}
}
},
"500": {
"description": "服务器内部错误",
"content": {
@@ -216,7 +195,7 @@
]
}
},
"/templates/{templateId}/batch-execute": {
"/api/v1/templates/{templateId}/batch-execute": {
"post": {
"description": "批量执行模板生成任务,支持多张图片同时处理",
"operationId": "TemplateController_batchExecuteTemplate",
@@ -306,7 +285,7 @@
]
}
},
"/templates": {
"/api/v1/templates": {
"get": {
"description": "获取所有可用的AI生成模板支持按类型筛选",
"operationId": "TemplateController_getAllTemplates",
@@ -433,7 +412,7 @@
]
}
},
"/templates/image": {
"/api/v1/templates/image": {
"get": {
"description": "获取所有图片类型的AI生成模板",
"operationId": "TemplateController_getImageTemplates",
@@ -489,7 +468,7 @@
]
}
},
"/templates/video": {
"/api/v1/templates/video": {
"get": {
"description": "获取所有视频类型的AI生成模板",
"operationId": "TemplateController_getVideoTemplates",
@@ -545,7 +524,7 @@
]
}
},
"/templates/recommend": {
"/api/v1/templates/recommend": {
"get": {
"description": "根据用户偏好标签推荐适合的模板",
"operationId": "TemplateController_recommendTemplates",
@@ -628,7 +607,7 @@
]
}
},
"/templates/{templateId}": {
"/api/v1/templates/{templateId}": {
"get": {
"description": "根据模板ID获取详细信息",
"operationId": "TemplateController_getTemplateById",
@@ -824,7 +803,7 @@
]
}
},
"/templates/execution/{taskId}/progress": {
"/api/v1/templates/execution/{taskId}/progress": {
"get": {
"operationId": "TemplateController_getExecutionProgress",
"parameters": [
@@ -877,7 +856,7 @@
]
}
},
"/templates/executions/user/{userId}": {
"/api/v1/templates/executions/user/{userId}": {
"get": {
"operationId": "TemplateController_getUserExecutions",
"parameters": [
@@ -946,7 +925,7 @@
]
}
},
"/templates/admin/{templateId}": {
"/api/v1/templates/admin/{templateId}": {
"get": {
"operationId": "TemplateController_getTemplateForAdmin",
"parameters": [
@@ -999,7 +978,7 @@
]
}
},
"/templates/admin": {
"/api/v1/templates/admin": {
"get": {
"operationId": "TemplateController_getAllTemplatesForAdmin",
"parameters": [
@@ -1076,7 +1055,56 @@
]
}
},
"/users/login": {
"/api/v1/enhanced/templates/code/{code}/execute": {
"post": {
"description": "统一异步模式:先提交审核,然后通过回调继续执行模板。支持实时状态查询。",
"operationId": "EnhancedTemplateController_executeTemplateByCode",
"parameters": [
{
"name": "code",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
}
],
"responses": {
"201": {
"description": ""
}
},
"summary": "异步执行模板 (增强版)",
"tags": [
"AI模板系统 (增强版)"
]
}
},
"/api/v1/enhanced/templates/{executionId}/status": {
"get": {
"operationId": "EnhancedTemplateController_getExecutionStatus",
"parameters": [
{
"name": "executionId",
"required": true,
"in": "path",
"schema": {
"type": "number"
}
}
],
"responses": {
"200": {
"description": ""
}
},
"summary": "查询执行状态 (增强版)",
"tags": [
"AI模板系统 (增强版)"
]
}
},
"/api/v1/users/login": {
"post": {
"description": "支持微信、支付宝、百度、字节跳动等8大平台的统一登录接口",
"operationId": "UnifiedUserController_login",
@@ -1127,7 +1155,7 @@
]
}
},
"/users/register": {
"/api/v1/users/register": {
"post": {
"description": "支持多平台用户注册,自动创建统一用户身份",
"operationId": "UnifiedUserController_register",
@@ -1167,7 +1195,7 @@
]
}
},
"/users/profile": {
"/api/v1/users/profile": {
"get": {
"description": "获取当前登录用户的详细信息和平台绑定状态",
"operationId": "UnifiedUserController_getProfile",
@@ -1252,7 +1280,7 @@
]
}
},
"/users/bind-platform": {
"/api/v1/users/bind-platform": {
"post": {
"description": "将其他平台账号绑定到当前统一用户身份",
"operationId": "UnifiedUserController_bindPlatform",
@@ -1299,7 +1327,7 @@
]
}
},
"/users/unbind-platform/{platform}": {
"/api/v1/users/unbind-platform/{platform}": {
"delete": {
"description": "解除指定平台账号与当前用户的绑定关系",
"operationId": "UnifiedUserController_unbindPlatform",
@@ -1345,7 +1373,7 @@
]
}
},
"/users/platforms": {
"/api/v1/users/platforms": {
"get": {
"description": "获取系统支持的所有平台类型和相关信息",
"operationId": "UnifiedUserController_getSupportedPlatforms",
@@ -1382,13 +1410,310 @@
"用户管理"
]
}
},
"/api/v1/content-moderation/{platform}/audit-image": {
"post": {
"operationId": "ContentModerationController_auditImage",
"parameters": [
{
"name": "platform",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ImageAuditDto"
}
}
}
},
"responses": {
"200": {
"description": "审核成功",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ContentAuditResponseDto"
}
}
}
}
},
"security": [
{
"bearer": []
}
],
"summary": "图片内容审核",
"tags": [
"内容审核"
]
}
},
"/api/v1/content-moderation/{platform}/audit-batch": {
"post": {
"operationId": "ContentModerationController_auditImageBatch",
"parameters": [
{
"name": "platform",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
},
"responses": {
"200": {
"description": "批量审核成功",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/BatchAuditResponseDto"
}
}
}
}
},
"security": [
{
"bearer": []
}
],
"summary": "批量图片审核",
"tags": [
"内容审核"
]
}
},
"/api/v1/content-moderation/{platform}/result/{taskId}": {
"get": {
"operationId": "ContentModerationController_getAuditResult",
"parameters": [
{
"name": "platform",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
},
{
"name": "taskId",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "查询成功",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ContentAuditResponseDto"
}
}
}
}
},
"security": [
{
"bearer": []
}
],
"summary": "查询审核结果",
"tags": [
"内容审核"
]
}
},
"/api/v1/content-moderation/{platform}/callback": {
"post": {
"operationId": "ContentModerationController_handleCallback",
"parameters": [
{
"name": "platform",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
}
],
"responses": {
"201": {
"description": ""
}
},
"summary": "审核结果回调",
"tags": [
"内容审核"
]
}
},
"/api/v1/content-moderation/history": {
"get": {
"operationId": "ContentModerationController_getAuditHistory",
"parameters": [],
"responses": {
"200": {
"description": ""
}
},
"security": [
{
"bearer": []
}
],
"summary": "获取审核历史",
"tags": [
"内容审核"
]
}
},
"/api/v1/content-moderation/stats": {
"get": {
"operationId": "ContentModerationController_getAuditStats",
"parameters": [
{
"name": "platform",
"required": true,
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "startDate",
"required": true,
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "endDate",
"required": true,
"in": "query",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "获取成功",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AuditStatsResponseDto"
}
}
}
}
},
"summary": "获取审核统计",
"tags": [
"内容审核"
]
}
},
"/api/v1/content-moderation/user-stats": {
"get": {
"operationId": "ContentModerationController_getUserAuditStats",
"parameters": [],
"responses": {
"200": {
"description": ""
}
},
"security": [
{
"bearer": []
}
],
"summary": "获取用户审核统计",
"tags": [
"内容审核"
]
}
},
"/api/v1/content-moderation/platforms": {
"get": {
"operationId": "ContentModerationController_getSupportedPlatforms",
"parameters": [],
"responses": {
"200": {
"description": ""
}
},
"summary": "获取支持的审核平台",
"tags": [
"内容审核"
]
}
},
"/api/v1/content-moderation/check/{taskId}": {
"get": {
"operationId": "ContentModerationController_checkContentApproval",
"parameters": [
{
"name": "taskId",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": ""
}
},
"summary": "检查内容是否通过审核",
"tags": [
"内容审核"
]
}
}
},
"info": {
"title": "多平台小程序统一后台API",
"description": "支持微信支付宝百度字节跳动等多平台的统一后台服务",
"description": "\n ## 功能特性\n - 🔐 统一用户认证 (微信/支付宝/百度/字节跳动等)\n - 🎨 AI模板系统 (图片/视频生成)\n - 💰 积分系统 (积分获取、消耗、管理)\n - 📱 多平台适配 (8大平台支持)\n - 🧩 扩展数据存储 (灵活的JSON数据)\n \n ## 认证方式\n 使用JWT Bearer Token进行API认证\n \n ## 响应格式\n 所有API响应都遵循统一格式\n ```json\n {\n \"code\": 200,\n \"message\": \"success\",\n \"data\": {},\n \"timestamp\": 1703001000000,\n \"traceId\": \"trace-uuid\"\n }\n ```\n ",
"version": "1.0.0",
"contact": {}
"contact": {
"name": "开发团队",
"url": "https://example.com",
"email": "dev@example.com"
},
"license": {
"name": "MIT",
"url": "https://opensource.org/licenses/MIT"
}
},
"tags": [
{
@@ -1412,7 +1737,20 @@
"description": "预留的扩展功能接口"
}
],
"servers": [],
"servers": [
{
"url": "http://localhost:3004",
"description": "开发环境"
},
{
"url": "https://sd2s2bl25ni4n75na2bog.apigateway-cn-beijing.volceapi.com",
"description": "测试环境"
},
{
"url": "https://sd2s2bl25ni4n75na2bog.apigateway-cn-beijing.volceapi.com",
"description": "生产环境"
}
],
"components": {
"securitySchemes": {
"JWT-auth": {
@@ -1966,6 +2304,207 @@
"platform",
"code"
]
},
"ImageAuditDto": {
"type": "object",
"properties": {
"imageUrl": {
"type": "string",
"description": "图片URL",
"example": "https://example.com/image.jpg"
},
"imageBase64": {
"type": "string",
"description": "图片Base64可选"
},
"taskId": {
"type": "string",
"description": "任务ID可选"
},
"businessType": {
"type": "string",
"description": "业务类型",
"example": "user_avatar"
},
"extraData": {
"type": "object",
"description": "扩展数据"
}
},
"required": [
"imageUrl"
]
},
"AuditDetailResponseDto": {
"type": "object",
"properties": {
"type": {
"type": "string",
"description": "检测类型"
},
"label": {
"type": "string",
"description": "具体标签"
},
"confidence": {
"type": "number",
"description": "置信度",
"example": 85
},
"description": {
"type": "string",
"description": "描述信息"
}
},
"required": [
"type",
"label",
"confidence",
"description"
]
},
"ContentAuditResponseDto": {
"type": "object",
"properties": {
"taskId": {
"type": "string",
"description": "任务ID"
},
"status": {
"type": "string",
"enum": [
"pending",
"processing",
"completed",
"failed",
"timeout"
],
"description": "审核状态"
},
"conclusion": {
"type": "string",
"enum": [
"pass",
"reject",
"review",
"uncertain"
],
"description": "审核结论"
},
"confidence": {
"type": "number",
"description": "置信度 (0-100)",
"example": 85
},
"details": {
"description": "详细审核结果",
"type": "array",
"items": {
"$ref": "#/components/schemas/AuditDetailResponseDto"
}
},
"riskLevel": {
"type": "string",
"enum": [
"low",
"medium",
"high",
"critical"
],
"description": "风险等级"
},
"suggestion": {
"type": "string",
"enum": [
"pass",
"block",
"human_review",
"delete"
],
"description": "建议操作"
},
"timestamp": {
"format": "date-time",
"type": "string",
"description": "审核时间"
}
},
"required": [
"taskId",
"status",
"conclusion",
"confidence",
"details",
"riskLevel",
"suggestion",
"timestamp"
]
},
"BatchAuditResponseDto": {
"type": "object",
"properties": {
"totalCount": {
"type": "number",
"description": "总数"
},
"successCount": {
"type": "number",
"description": "成功数"
},
"failureCount": {
"type": "number",
"description": "失败数"
},
"results": {
"description": "审核结果列表",
"type": "array",
"items": {
"$ref": "#/components/schemas/ContentAuditResponseDto"
}
}
},
"required": [
"totalCount",
"successCount",
"failureCount",
"results"
]
},
"AuditStatsResponseDto": {
"type": "object",
"properties": {
"totalAudits": {
"type": "number",
"description": "总审核数"
},
"passRate": {
"type": "number",
"description": "通过率 (%)",
"example": 85.5
},
"rejectRate": {
"type": "number",
"description": "拒绝率 (%)",
"example": 10.2
},
"reviewRate": {
"type": "number",
"description": "复审率 (%)",
"example": 4.3
},
"averageConfidence": {
"type": "number",
"description": "平均置信度",
"example": 88.7
}
},
"required": [
"totalAudits",
"passRate",
"rejectRate",
"reviewRate",
"averageConfidence"
]
}
}
}