diff --git a/.env.example b/.env.example index 6a6a802..29dc9b2 100644 --- a/.env.example +++ b/.env.example @@ -4,30 +4,30 @@ DB_PORT=53305 DB_USERNAME=root DB_PASSWORD=WsJWXfwFx0bq6DE2kmB6 DB_DATABASE=nano_camera_miniapp -DB_LOGGING=true -DB_MIGRATIONS_RUN=true +DB_LOGGING=false +DB_MIGRATIONS_RUN=false # 应用配置 NODE_ENV=development -PORT=3000 +PORT=3003 # N8N配置 -N8N_WEBHOOK_URL=https://n8n.bowongai.com/webhook/76f92dbf-785f-4add-96b5-a108174b7c14 +N8N_WEBHOOK_URL=https://n8n.bowongai.com/webhook/f1487ca8-bc49-4994-ba82-e2bcb95931f9 # JWT配置 -JWT_SECRET=your_jwt_secret_key_here +JWT_SECRET=a6e4d948295ec0ae53921d67d4ce97cfff0565073e370d6094e43705cd48914b68d383feba8b6bcc8e113b090b6d4e5b306cf8b758c71aff7c0910ecb2bacfb8 # 微信小程序配置 -WECHAT_APP_ID=your_wechat_app_id +WECHAT_APP_ID=wxb51f0b0c3aad7cdf WECHAT_APP_SECRET=your_wechat_app_secret # 抖音小程序配置 -BYTEDANCE_APP_ID=your_bytedance_app_id -BYTEDANCE_APP_SECRET=your_bytedance_app_secret +BYTEDANCE_APP_ID=ttbfd9c96420ec8f8201 +BYTEDANCE_APP_SECRET=04a026867fbd1ba52174c7c21d94cbc7361ec378 # 内容审核配置 # 图片审核回调地址(重要:抖音审核完成后会调用此接口) -AUDIT_CALLBACK_URL=https://your-domain.com/api/v1/content-moderation/callback +AUDIT_CALLBACK_URL=https://sd2s2bl25ni4n75na2bog.apigateway-cn-beijing.volceapi.com/api/v1/content-moderation/bytedance/callback # 抖音内容审核API地址 BYTEDANCE_AUDIT_API_URL=https://developer.toutiao.com/api/apps/v2/content/audit/image diff --git a/docs/api-spec.json b/docs/api-spec.json index 7d6c640..39ee40c 100644 --- a/docs/api-spec.json +++ b/docs/api-spec.json @@ -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" + ] } } } diff --git a/src/content-moderation/controllers/content-moderation.controller.ts b/src/content-moderation/controllers/content-moderation.controller.ts index e581d01..22909a3 100644 --- a/src/content-moderation/controllers/content-moderation.controller.ts +++ b/src/content-moderation/controllers/content-moderation.controller.ts @@ -35,7 +35,7 @@ const CurrentUser = () => { }; @ApiTags('内容审核') -@Controller('api/v1/content-moderation') +@Controller('content-moderation') export class ContentModerationController { constructor(private readonly unifiedContentService: UnifiedContentService) {} diff --git a/src/generate-swagger-json.ts b/src/generate-swagger-json.ts index 79e94fc..4f2ea81 100644 --- a/src/generate-swagger-json.ts +++ b/src/generate-swagger-json.ts @@ -6,10 +6,41 @@ import * as fs from 'fs'; async function generateSwaggerJson() { const app = await NestFactory.create(AppModule, { logger: false }); + // 设置API前缀(与main.ts保持一致) + app.setGlobalPrefix('api/v1', { + exclude: ['docs', 'docs/(.*)'], + }); + const config = new DocumentBuilder() .setTitle('多平台小程序统一后台API') - .setDescription('支持微信、支付宝、百度、字节跳动等多平台的统一后台服务') + .setDescription( + ` + ## 功能特性 + - 🔐 统一用户认证 (微信/支付宝/百度/字节跳动等) + - 🎨 AI模板系统 (图片/视频生成) + - 💰 积分系统 (积分获取、消耗、管理) + - 📱 多平台适配 (8大平台支持) + - 🧩 扩展数据存储 (灵活的JSON数据) + + ## 认证方式 + 使用JWT Bearer Token进行API认证 + + ## 响应格式 + 所有API响应都遵循统一格式: + \`\`\`json + { + "code": 200, + "message": "success", + "data": {}, + "timestamp": 1703001000000, + "traceId": "trace-uuid" + } + \`\`\` + `, + ) .setVersion('1.0.0') + .setContact('开发团队', 'https://example.com', 'dev@example.com') + .setLicense('MIT', 'https://opensource.org/licenses/MIT') .addBearerAuth( { type: 'http', @@ -26,6 +57,9 @@ async function generateSwaggerJson() { .addTag('AI模板系统', 'AI图片/视频生成模板管理') .addTag('积分系统', '积分获取、消耗、查询管理') .addTag('扩展服务', '预留的扩展功能接口') + .addServer(`http://localhost:${process.env.PORT || 3003}`, '开发环境') + .addServer(process.env.TEST_SERVER_URL || 'https://sd2s2bl25ni4n75na2bog.apigateway-cn-beijing.volceapi.com', '测试环境') + .addServer(process.env.PROD_SERVER_URL || 'https://sd2s2bl25ni4n75na2bog.apigateway-cn-beijing.volceapi.com', '生产环境') .build(); const document = SwaggerModule.createDocument(app as any, config); diff --git a/src/main.ts b/src/main.ts index 4c2d836..71b1076 100644 --- a/src/main.ts +++ b/src/main.ts @@ -32,8 +32,7 @@ async function bootstrap() { // 启用 CORS 支持多平台访问 app.enableCors({ - origin: - process.env.NODE_ENV === 'production' ? ['https://example.com'] : true, + origin: true, methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'], allowedHeaders: ['Content-Type', 'Authorization', 'X-Requested-With'], credentials: true, diff --git a/swagger.json b/swagger.json index 7d6c640..39ee40c 100644 --- a/swagger.json +++ b/swagger.json @@ -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" + ] } } }