feat(reset): 以构造器模式重构
- 加了大文件传输自定义分片协议 BREAKING CHANGES: 0.1.0(latest)
This commit is contained in:
@@ -1,52 +1,26 @@
|
||||
import type { BaseEntityContent, Post, PostComment } from './base';
|
||||
import type {
|
||||
PostType,
|
||||
PostSortBy,
|
||||
CommentSortBy,
|
||||
SortOrder
|
||||
} from './enum';
|
||||
import type { Post, PostComment, PostType, PostContent } from './base';
|
||||
import type { PaginationRequest, PaginationResponse } from '../common';
|
||||
|
||||
// 创建帖子请求接口
|
||||
export interface CreatePostRequest extends BaseEntityContent {
|
||||
type: PostType; // 帖子类型:提问或文章
|
||||
images?: string[]; // 图片
|
||||
publishedAt?: Date; // 发布时间
|
||||
export interface CreatePostRequest {
|
||||
title: string;
|
||||
content: PostContent;
|
||||
type: PostType;
|
||||
}
|
||||
|
||||
// 创建帖子响应接口
|
||||
// 创建帖子响应接口(整体替换资源,直接返回结果就够了)
|
||||
export interface CreatePostResponse {
|
||||
post: Post;
|
||||
success: boolean;
|
||||
}
|
||||
|
||||
// 获取帖子列表请求接口
|
||||
export interface GetPostsRequest {
|
||||
page?: number; // 页码
|
||||
limit?: number; // 每页数量
|
||||
sortBy?: PostSortBy; // 帖子排序方式
|
||||
type?: PostType; // 帖子类型:提问或文章
|
||||
sortOrder?: SortOrder; // 排序方向
|
||||
authorId?: string;
|
||||
search?: string;
|
||||
// 获取帖子列表请求接口(简单,但是为了之后的扩展性保持独立)
|
||||
export interface GetPostsRequest extends PaginationRequest {
|
||||
// 已继承page和limit字段
|
||||
}
|
||||
|
||||
// 获取帖子列表响应接口
|
||||
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 GetPostsResponse extends PaginationResponse<Post> {
|
||||
// 已继承所有分页相关字段
|
||||
}
|
||||
|
||||
// 点赞帖子请求接口
|
||||
@@ -71,6 +45,7 @@ export interface BookmarkPostResponse {
|
||||
|
||||
// 创建评论请求接口
|
||||
export interface CreateCommentRequest {
|
||||
// 作者信息让后端去计算,保持纯粹性
|
||||
postId: string;
|
||||
content: string;
|
||||
parentId?: string;
|
||||
@@ -78,43 +53,25 @@ export interface CreateCommentRequest {
|
||||
|
||||
// 创建评论响应接口
|
||||
export interface CreateCommentResponse {
|
||||
comment: PostComment;
|
||||
success: boolean;
|
||||
}
|
||||
|
||||
|
||||
// 获取评论列表请求接口
|
||||
export interface GetCommentsRequest {
|
||||
page?: number; // 页码
|
||||
limit?: number; // 每页数量
|
||||
sortOrder?: SortOrder; // 排序方向
|
||||
export interface GetCommentsRequest extends PaginationRequest {
|
||||
postId: string;
|
||||
parentId?: string;
|
||||
sortBy?: CommentSortBy;
|
||||
}
|
||||
|
||||
// 获取评论列表响应接口
|
||||
export interface GetCommentsResponse {
|
||||
data: PostComment[]; // 数据列表
|
||||
total: number; // 总数
|
||||
page: number; // 当前页码
|
||||
limit: number; // 每页数量
|
||||
hasMore: boolean; // 是否有更多数据
|
||||
export interface GetCommentsResponse extends PaginationResponse<PostComment> {
|
||||
// 已继承所有分页相关字段
|
||||
}
|
||||
|
||||
// 点赞评论请求接口
|
||||
export interface LikeCommentRequest {
|
||||
commentId: string;
|
||||
}
|
||||
|
||||
// 点赞评论响应接口
|
||||
export interface LikeCommentResponse {
|
||||
success: boolean;
|
||||
}
|
||||
|
||||
// 获取热门帖子请求接口
|
||||
export interface GetHotPostsRequest {
|
||||
limit?: number; // 每页数量
|
||||
days?: number; // 统计天数,默认7天
|
||||
// 获取热门帖子请求接口(简单,独立,扩展性)
|
||||
export interface GetHotPostsRequest extends PaginationRequest {
|
||||
// 已继承limit字段
|
||||
// 用不着统计天数
|
||||
}
|
||||
|
||||
// 获取热门帖子响应接口
|
||||
@@ -123,22 +80,18 @@ export interface GetHotPostsResponse {
|
||||
total: number; // 总数
|
||||
}
|
||||
|
||||
// 获取帖子榜单请求接口
|
||||
export interface GetPostRankingRequest {
|
||||
limit?: number; // 每页数量
|
||||
period?: 'day' | 'week' | 'month'; // 统计周期
|
||||
type?: 'views' | 'likes' | 'comments'; // 排序类型
|
||||
// 获取帖子榜单请求接口(简单,独立,扩展性)
|
||||
export interface GetPostRankingRequest extends PaginationRequest {
|
||||
// 已继承limit字段
|
||||
}
|
||||
|
||||
// 获取帖子榜单响应接口
|
||||
// 获取帖子榜单响应接口(不存在无限滚动的可能)
|
||||
export interface GetPostRankingResponse {
|
||||
data: Post[]; // 数据列表
|
||||
total: number; // 总数
|
||||
period: 'day' | 'week' | 'month'; // 统计周期
|
||||
type: 'views' | 'likes' | 'comments'; // 排序类型
|
||||
}
|
||||
|
||||
// 后面全部暂时不考虑
|
||||
// 后面全部暂时不会实现
|
||||
// 删除帖子请求接口
|
||||
export interface DeletePostRequest {
|
||||
postId: string;
|
||||
|
||||
Reference in New Issue
Block a user