105 lines
2.5 KiB
TypeScript
105 lines
2.5 KiB
TypeScript
import type { Post, PostComment, PostType, PostContent } from './base';
|
|
import type { PaginationRequest, PaginationResponse } from '../common';
|
|
|
|
// 创建帖子请求接口
|
|
export interface CreatePostRequest {
|
|
title: string;
|
|
content: PostContent;
|
|
type: PostType;
|
|
}
|
|
|
|
// 创建帖子响应接口(整体替换资源,直接返回结果就够了)
|
|
export interface CreatePostResponse {
|
|
success: boolean;
|
|
}
|
|
|
|
// 获取帖子列表请求接口(简单,但是为了之后的扩展性保持独立)
|
|
export interface GetPostsRequest extends PaginationRequest {
|
|
// 已继承page和limit字段
|
|
}
|
|
|
|
// 获取帖子列表响应接口
|
|
export interface GetPostsResponse extends PaginationResponse<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 {
|
|
success: boolean;
|
|
}
|
|
|
|
|
|
// 获取评论列表请求接口
|
|
export interface GetCommentsRequest extends PaginationRequest {
|
|
postId: string;
|
|
parentId?: string;
|
|
}
|
|
|
|
// 获取评论列表响应接口
|
|
export interface GetCommentsResponse extends PaginationResponse<PostComment> {
|
|
// 已继承所有分页相关字段
|
|
}
|
|
|
|
// 获取热门帖子请求接口(简单,独立,扩展性)
|
|
export interface GetHotPostsRequest extends PaginationRequest {
|
|
// 已继承limit字段
|
|
// 用不着统计天数
|
|
}
|
|
|
|
// 获取热门帖子响应接口
|
|
export interface GetHotPostsResponse {
|
|
data: Post[]; // 数据列表
|
|
total: number; // 总数
|
|
}
|
|
|
|
// 获取帖子榜单请求接口(简单,独立,扩展性)
|
|
export interface GetPostRankingRequest extends PaginationRequest {
|
|
// 已继承limit字段
|
|
}
|
|
|
|
// 获取帖子榜单响应接口(不存在无限滚动的可能)
|
|
export interface GetPostRankingResponse {
|
|
data: Post[]; // 数据列表
|
|
total: number; // 总数
|
|
}
|
|
|
|
// 后面全部暂时不会实现
|
|
// 删除帖子请求接口
|
|
export interface DeletePostRequest {
|
|
postId: string;
|
|
}
|
|
|
|
// 删除帖子响应接口
|
|
export interface DeletePostResponse {
|
|
success: boolean;
|
|
}
|
|
|