feat(api): 添加热门卡片与榜单接口及实现

- 新增热门帖子、热门作者、榜单接口及实现
- 新增api-documentation,更好的ai协作
- 修复types没有导出的问题

BREAKING CHANGES: 1.0.0->1.1.0(latest)
This commit is contained in:
tobegold574
2025-11-18 22:29:40 +08:00
parent c3a8a525cb
commit a0c907beed
28 changed files with 1074 additions and 15 deletions

151
types/post/api.ts Normal file
View File

@@ -0,0 +1,151 @@
import type { BaseEntityContent, Post, PostComment } from './base';
import type {
PostType,
PostSortBy,
CommentSortBy,
SortOrder
} from './enum';
// 创建帖子请求接口
export interface CreatePostRequest extends BaseEntityContent {
type: PostType; // 帖子类型:提问或文章
images?: string[]; // 图片
publishedAt?: Date; // 发布时间
}
// 创建帖子响应接口
export interface CreatePostResponse {
post: Post;
}
// 获取帖子列表请求接口
export interface GetPostsRequest {
page?: number; // 页码
limit?: number; // 每页数量
sortBy?: PostSortBy; // 帖子排序方式
type?: PostType; // 帖子类型:提问或文章
sortOrder?: SortOrder; // 排序方向
authorId?: string;
search?: string;
}
// 获取帖子列表响应接口
export interface GetPostsResponse {
data: Post[]; // 数据列表
total: number; // 总数
page: number; // 当前页码
limit: number; // 每页数量
hasMore: boolean; // 是否有更多数据
sortBy?: PostSortBy; // 帖子排序方式
}
// 获取帖子详情请求接口
export interface GetPostRequest {
postId: string;
}
// 获取帖子详情响应接口
export interface GetPostResponse {
post: Post;
}
// 点赞帖子请求接口
export interface LikePostRequest {
postId: string;
}
// 点赞帖子响应接口
export interface LikePostResponse {
success: boolean;
}
// 收藏帖子请求接口
export interface BookmarkPostRequest {
postId: string;
}
// 收藏帖子响应接口
export interface BookmarkPostResponse {
success: boolean;
}
// 创建评论请求接口
export interface CreateCommentRequest {
postId: string;
content: string;
parentId?: string;
}
// 创建评论响应接口
export interface CreateCommentResponse {
comment: PostComment;
}
// 获取评论列表请求接口
export interface GetCommentsRequest {
page?: number; // 页码
limit?: number; // 每页数量
sortOrder?: SortOrder; // 排序方向
postId: string;
parentId?: string;
sortBy?: CommentSortBy;
}
// 获取评论列表响应接口
export interface GetCommentsResponse {
data: PostComment[]; // 数据列表
total: number; // 总数
page: number; // 当前页码
limit: number; // 每页数量
hasMore: boolean; // 是否有更多数据
}
// 点赞评论请求接口
export interface LikeCommentRequest {
commentId: string;
}
// 点赞评论响应接口
export interface LikeCommentResponse {
success: boolean;
}
// 获取热门帖子请求接口
export interface GetHotPostsRequest {
limit?: number; // 每页数量
days?: number; // 统计天数默认7天
}
// 获取热门帖子响应接口
export interface GetHotPostsResponse {
data: Post[]; // 数据列表
total: number; // 总数
}
// 获取帖子榜单请求接口
export interface GetPostRankingRequest {
limit?: number; // 每页数量
period?: 'day' | 'week' | 'month'; // 统计周期
type?: 'views' | 'likes' | 'comments'; // 排序类型
}
// 获取帖子榜单响应接口
export interface GetPostRankingResponse {
data: Post[]; // 数据列表
total: number; // 总数
period: 'day' | 'week' | 'month'; // 统计周期
type: 'views' | 'likes' | 'comments'; // 排序类型
}
// 后面全部暂时不考虑
// 删除帖子请求接口
export interface DeletePostRequest {
postId: string;
}
// 删除帖子响应接口
export interface DeletePostResponse {
success: boolean;
}