This commit is contained in:
2025-03-10 18:55:33 +08:00
parent e49b3a2172
commit 5ef6c75360
3 changed files with 1787 additions and 173 deletions

View File

@@ -1555,7 +1555,876 @@ export const openAPISpec = {
}
}
}
}
},
'/api/analytics/influencer/track': {
post: {
tags: ['Analytics'],
summary: '追踪网红指标变化',
description: '记录网红账号的关键指标(如粉丝数、视频数等)变化',
security: [{ bearerAuth: [] }],
requestBody: {
required: true,
content: {
'application/json': {
schema: {
type: 'object',
required: ['influencer_id', 'metrics'],
properties: {
influencer_id: { type: 'string', format: 'uuid', description: '网红ID' },
metrics: {
type: 'object',
properties: {
followers_count: { type: 'number', description: '粉丝数量' },
video_count: { type: 'number', description: '视频数量' },
views_count: { type: 'number', description: '总观看数' },
likes_count: { type: 'number', description: '总点赞数' }
}
}
}
}
}
}
},
responses: {
'200': {
description: '成功追踪网红指标',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
message: { type: 'string', example: 'Influencer metrics tracked successfully' },
influencer_id: { type: 'string', format: 'uuid' },
tracked_metrics: {
type: 'object',
properties: {
followers_count: { type: 'number' },
video_count: { type: 'number' }
}
}
}
}
}
}
},
'400': {
description: '请求参数错误',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/Error'
}
}
}
},
'401': {
description: '未授权',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/Error'
}
}
}
},
'500': {
description: '服务器内部错误',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/Error'
}
}
}
}
}
}
},
'/api/analytics/influencer/{id}/growth': {
get: {
tags: ['Analytics'],
summary: '获取网红粉丝增长趋势',
description: '按不同时间粒度(天/周/月)获取网红的粉丝或其他指标变化趋势',
security: [{ bearerAuth: [] }],
parameters: [
{
name: 'id',
in: 'path',
required: true,
schema: { type: 'string', format: 'uuid' },
description: '网红ID'
},
{
name: 'metric',
in: 'query',
schema: {
type: 'string',
enum: ['followers_count', 'video_count', 'views_count', 'likes_count'],
default: 'followers_count'
},
description: '要分析的指标'
},
{
name: 'timeframe',
in: 'query',
schema: {
type: 'string',
enum: ['30days', '90days', '6months', '1year'],
default: '6months'
},
description: '分析的时间范围'
},
{
name: 'interval',
in: 'query',
schema: {
type: 'string',
enum: ['day', 'week', 'month'],
default: 'month'
},
description: '数据聚合的时间间隔'
}
],
responses: {
'200': {
description: '网红增长趋势数据',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
influencer_id: { type: 'string', format: 'uuid' },
influencer_info: {
type: 'object',
properties: {
name: { type: 'string' },
platform: { type: 'string' },
followers_count: { type: 'number' }
}
},
metric: { type: 'string' },
timeframe: { type: 'string' },
interval: { type: 'string' },
data: {
type: 'array',
items: {
type: 'object',
properties: {
time_period: { type: 'string', format: 'date' },
change: { type: 'number' },
total_value: { type: 'number' }
}
}
}
}
}
}
}
},
'401': {
description: '未授权',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/Error'
}
}
}
},
'500': {
description: '服务器内部错误',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/Error'
}
}
}
}
}
}
},
'/api/analytics/content/track': {
post: {
tags: ['Analytics'],
summary: '追踪内容互动数据',
description: '记录文章/内容的互动数据变化(如观看数、点赞数等)',
security: [{ bearerAuth: [] }],
requestBody: {
required: true,
content: {
'application/json': {
schema: {
type: 'object',
required: ['post_id', 'metrics'],
properties: {
post_id: { type: 'string', format: 'uuid', description: '文章ID' },
metrics: {
type: 'object',
properties: {
views_count: { type: 'number', description: '观看数量' },
likes_count: { type: 'number', description: '点赞数量' },
comments_count: { type: 'number', description: '评论数量' },
shares_count: { type: 'number', description: '分享数量' }
}
}
}
}
}
}
},
responses: {
'200': {
description: '成功追踪内容指标',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
message: { type: 'string', example: 'Post metrics tracked successfully' },
post_id: { type: 'string', format: 'uuid' },
tracked_metrics: {
type: 'object',
properties: {
views_count: { type: 'number' },
likes_count: { type: 'number' },
comments_count: { type: 'number' },
shares_count: { type: 'number' }
}
}
}
}
}
}
},
'400': {
description: '请求参数错误',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/Error'
}
}
}
}
}
}
},
'/api/analytics/content/{id}/trends': {
get: {
tags: ['Analytics'],
summary: '获取内容互动趋势',
description: '按不同时间粒度查看内容的互动数据变化趋势',
security: [{ bearerAuth: [] }],
parameters: [
{
name: 'id',
in: 'path',
required: true,
schema: { type: 'string', format: 'uuid' },
description: '文章ID'
},
{
name: 'metric',
in: 'query',
schema: {
type: 'string',
enum: ['views_count', 'likes_count', 'comments_count', 'shares_count'],
default: 'views_count'
},
description: '要分析的指标'
},
{
name: 'timeframe',
in: 'query',
schema: {
type: 'string',
enum: ['7days', '30days', '90days'],
default: '30days'
},
description: '分析的时间范围'
},
{
name: 'interval',
in: 'query',
schema: {
type: 'string',
enum: ['hour', 'day', 'week'],
default: 'day'
},
description: '数据聚合的时间间隔'
}
],
responses: {
'200': {
description: '内容互动趋势数据',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
post_id: { type: 'string', format: 'uuid' },
post_info: {
type: 'object',
properties: {
title: { type: 'string' },
platform: { type: 'string' },
published_at: { type: 'string', format: 'date-time' }
}
},
metric: { type: 'string' },
timeframe: { type: 'string' },
interval: { type: 'string' },
data: {
type: 'array',
items: {
type: 'object',
properties: {
time_period: { type: 'string', format: 'date' },
change: { type: 'number' },
total_value: { type: 'number' }
}
}
}
}
}
}
}
}
}
}
},
'/api/analytics/project/{id}/overview': {
get: {
tags: ['Analytics'],
summary: '获取项目整体分析',
description: '获取项目的整体表现数据,包括关键指标、平台分布和时间线',
security: [{ bearerAuth: [] }],
parameters: [
{
name: 'id',
in: 'path',
required: true,
schema: { type: 'string', format: 'uuid' },
description: '项目ID'
},
{
name: 'timeframe',
in: 'query',
schema: {
type: 'string',
enum: ['7days', '30days', '90days', '6months'],
default: '30days'
},
description: '分析的时间范围'
}
],
responses: {
'200': {
description: '项目概览数据',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
project: {
type: 'object',
properties: {
id: { type: 'string', format: 'uuid' },
name: { type: 'string' },
description: { type: 'string' },
created_at: { type: 'string', format: 'date-time' }
}
},
timeframe: { type: 'string' },
metrics: {
type: 'object',
properties: {
total_influencers: { type: 'number' },
total_posts: { type: 'number' },
total_views: { type: 'number' },
total_likes: { type: 'number' },
total_comments: { type: 'number' },
total_shares: { type: 'number' },
total_followers: { type: 'number' }
}
},
platforms: {
type: 'array',
items: {
type: 'object',
properties: {
platform: { type: 'string' },
count: { type: 'number' },
percentage: { type: 'number' }
}
}
},
timeline: {
type: 'array',
items: {
type: 'object',
properties: {
date: { type: 'string', format: 'date' },
views_change: { type: 'number' },
likes_change: { type: 'number' },
comments_change: { type: 'number' },
shares_change: { type: 'number' },
followers_change: { type: 'number' }
}
}
}
}
}
},
'text/csv': {
schema: {
type: 'string'
}
}
}
}
}
}
},
'/api/analytics/project/{id}/top-performers': {
get: {
tags: ['Analytics'],
summary: '获取项目中表现最佳的网红',
description: '获取项目中表现最佳的网红列表,可按不同指标排序',
security: [{ bearerAuth: [] }],
parameters: [
{
name: 'id',
in: 'path',
required: true,
schema: { type: 'string', format: 'uuid' },
description: '项目ID'
},
{
name: 'metric',
in: 'query',
schema: {
type: 'string',
enum: ['views_count', 'likes_count', 'followers_count', 'engagement_rate'],
default: 'views_count'
},
description: '排序指标'
},
{
name: 'limit',
in: 'query',
schema: {
type: 'string',
default: '10'
},
description: '返回结果数量'
},
{
name: 'timeframe',
in: 'query',
schema: {
type: 'string',
enum: ['7days', '30days', '90days', '6months'],
default: '30days'
},
description: '分析的时间范围'
}
],
responses: {
'200': {
description: '表现最佳的网红列表',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
project_id: { type: 'string', format: 'uuid' },
metric: { type: 'string' },
timeframe: { type: 'string' },
top_performers: {
type: 'array',
items: {
type: 'object',
properties: {
influencer_id: { type: 'string', format: 'uuid' },
name: { type: 'string' },
platform: { type: 'string' },
profile_url: { type: 'string' },
followers_count: { type: 'number' },
video_count: { type: 'number' },
views_count: { type: 'number' },
engagement_rate: { type: 'number' }
}
}
}
}
}
}
}
}
}
}
},
'/api/analytics/schedule/influencer': {
post: {
tags: ['Analytics', 'Scheduled Collection'],
summary: '调度网红数据采集',
description: '设置定时采集网红指标数据的任务',
security: [{ bearerAuth: [] }],
requestBody: {
required: true,
content: {
'application/json': {
schema: {
type: 'object',
required: ['influencer_id'],
properties: {
influencer_id: { type: 'string', format: 'uuid', description: '网红ID' },
cron_expression: {
type: 'string',
description: 'Cron表达式默认为每天午夜执行 (0 0 * * *)',
example: '0 0 * * *'
}
}
}
}
}
},
responses: {
'200': {
description: '成功调度数据采集',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
message: { type: 'string' },
influencer_id: { type: 'string', format: 'uuid' },
cron_expression: { type: 'string' }
}
}
}
}
}
}
}
},
'/api/analytics/schedule/post': {
post: {
tags: ['Analytics', 'Scheduled Collection'],
summary: '调度内容数据采集',
description: '设置定时采集内容指标数据的任务',
security: [{ bearerAuth: [] }],
requestBody: {
required: true,
content: {
'application/json': {
schema: {
type: 'object',
required: ['post_id'],
properties: {
post_id: { type: 'string', format: 'uuid', description: '文章ID' },
cron_expression: {
type: 'string',
description: 'Cron表达式默认为每天午夜执行 (0 0 * * *)',
example: '0 0 * * *'
}
}
}
}
}
},
responses: {
'200': {
description: '成功调度数据采集',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
message: { type: 'string' },
post_id: { type: 'string', format: 'uuid' },
cron_expression: { type: 'string' }
}
}
}
}
}
}
}
},
'/api/analytics/schedule': {
get: {
tags: ['Analytics', 'Scheduled Collection'],
summary: '获取所有调度任务',
description: '获取所有已设置的定时数据采集任务',
security: [{ bearerAuth: [] }],
responses: {
'200': {
description: '调度任务列表',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
scheduled_jobs: {
type: 'array',
items: {
type: 'object',
properties: {
id: { type: 'string' },
name: { type: 'string' },
pattern: { type: 'string' },
next: { type: 'string', format: 'date-time' }
}
}
}
}
}
}
}
}
}
}
},
'/api/analytics/schedule/{job_id}': {
delete: {
tags: ['Analytics', 'Scheduled Collection'],
summary: '删除调度任务',
description: '删除一个已创建的定时数据采集任务',
security: [{ bearerAuth: [] }],
parameters: [
{
name: 'job_id',
in: 'path',
required: true,
schema: { type: 'string' },
description: '任务ID'
}
],
responses: {
'200': {
description: '成功删除任务',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
message: { type: 'string' },
job_id: { type: 'string' }
}
}
}
}
}
}
}
},
'/api/analytics/export/influencer/{id}/growth': {
get: {
tags: ['Analytics', 'Data Export'],
summary: '导出网红增长数据',
description: '导出网红指标增长数据为CSV格式',
security: [{ bearerAuth: [] }],
parameters: [
{
name: 'id',
in: 'path',
required: true,
schema: { type: 'string', format: 'uuid' },
description: '网红ID'
},
{
name: 'metric',
in: 'query',
schema: {
type: 'string',
enum: ['followers_count', 'video_count', 'views_count', 'likes_count'],
default: 'followers_count'
},
description: '要导出的指标'
},
{
name: 'timeframe',
in: 'query',
schema: {
type: 'string',
enum: ['30days', '90days', '6months', '1year'],
default: '6months'
},
description: '导出的时间范围'
},
{
name: 'interval',
in: 'query',
schema: {
type: 'string',
enum: ['day', 'week', 'month'],
default: 'month'
},
description: '数据聚合的时间间隔'
}
],
responses: {
'200': {
description: 'CSV格式的网红增长数据',
content: {
'text/csv': {
schema: {
type: 'string'
}
}
}
}
}
}
},
'/api/analytics/export/project/{id}/performance': {
get: {
tags: ['Analytics', 'Data Export'],
summary: '导出项目表现数据',
description: '导出项目表现数据为CSV格式',
security: [{ bearerAuth: [] }],
parameters: [
{
name: 'id',
in: 'path',
required: true,
schema: { type: 'string', format: 'uuid' },
description: '项目ID'
},
{
name: 'timeframe',
in: 'query',
schema: {
type: 'string',
enum: ['7days', '30days', '90days', '6months'],
default: '30days'
},
description: '导出的时间范围'
}
],
responses: {
'200': {
description: 'CSV格式的项目表现数据',
content: {
'text/csv': {
schema: {
type: 'string'
}
}
}
}
}
}
},
'/api/analytics/reports/project/{id}': {
get: {
tags: ['Analytics', 'Reports'],
summary: '生成项目报告',
description: '生成项目表现的详细报告',
security: [{ bearerAuth: [] }],
parameters: [
{
name: 'id',
in: 'path',
required: true,
schema: { type: 'string', format: 'uuid' },
description: '项目ID'
},
{
name: 'timeframe',
in: 'query',
schema: {
type: 'string',
enum: ['7days', '30days', '90days', '6months'],
default: '30days'
},
description: '报告的时间范围'
},
{
name: 'format',
in: 'query',
schema: {
type: 'string',
enum: ['json', 'csv'],
default: 'json'
},
description: '报告格式'
}
],
responses: {
'200': {
description: '项目报告',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
report_type: { type: 'string' },
generated_at: { type: 'string', format: 'date-time' },
timeframe: { type: 'string' },
project: {
type: 'object',
properties: {
id: { type: 'string', format: 'uuid' },
name: { type: 'string' },
description: { type: 'string' }
}
},
summary: {
type: 'object',
properties: {
total_influencers: { type: 'number' },
total_posts: { type: 'number' },
total_views_gain: { type: 'number' },
total_likes_gain: { type: 'number' },
total_followers_gain: { type: 'number' }
}
},
top_influencers: {
type: 'array',
items: {
type: 'object',
properties: {
influencer_id: { type: 'string', format: 'uuid' },
name: { type: 'string' },
platform: { type: 'string' },
followers_count: { type: 'number' },
total_views_gain: { type: 'number' }
}
}
},
top_posts: {
type: 'array',
items: {
type: 'object',
properties: {
post_id: { type: 'string', format: 'uuid' },
title: { type: 'string' },
platform: { type: 'string' },
published_at: { type: 'string', format: 'date-time' },
influencer_name: { type: 'string' },
views_count: { type: 'number' },
likes_count: { type: 'number' },
engagement_rate: { type: 'number' }
}
}
}
}
}
},
'text/csv': {
schema: {
type: 'string'
}
}
}
}
}
}
},
},
components: {
schemas: {