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

160
types/model/api.ts Normal file
View File

@@ -0,0 +1,160 @@
import type { ModelComment, AIModel } from './base';
import type { CommentSortType } from './enum';
// AI模型榜单项接口
export interface AIModelRankingItem {
model: AIModel;
rank: number;
change?: 'up' | 'down' | 'same'; // 排名变化,未来扩展
}
// 获取AI模型广场数据请求接口
export interface GetAIPlazaRequest {
// 模型卡片数据是静态配置(手动维护)的,不需要分页参数
}
// 获取AI模型广场数据响应接口
export interface GetAIPlazaResponse {
models: AIModel[]; // 模型卡片列表,由管理员预定义
hotRankings: AIModelRankingItem[]; // 热评模型榜单
clickRankings: AIModelRankingItem[]; // 点击排行榜
}
// 获取模型详情请求接口
export interface GetModelDetailRequest {
modelId: string;
page?: number; // 评论页码
limit?: number; // 每页评论数量
sortBy?: CommentSortType; // 评论排序方式,未来扩展功能
}
// 获取模型详情响应接口
export interface GetModelDetailResponse {
model: AIModel;
comments: ModelComment[]; // 使用新的ModelComment类型已经是数组
totalComments: number;
hasMoreComments: boolean; // 是否还有更多评论,支持无限滚动加载
}
// 批量获取模型评论请求接口
export interface GetModelCommentsRequest {
modelId: string;
page?: number; // 页码
limit?: number; // 每页评论数量
sortBy?: CommentSortType; // 评论排序方式
parentId?: string; // 父评论ID用于获取回复
}
// 批量获取模型评论响应接口
export interface GetModelCommentsResponse {
comments: ModelComment[]; // 评论列表
total: number; // 总数
page: number; // 当前页码
limit: number; // 每页数量
hasMore: boolean; // 是否有更多数据
}
// 发表模型评论请求接口
export interface CreateModelCommentRequest {
modelId: string;
content: string;
parentId?: string; // 父评论ID用于回复评论
}
// 发表模型评论响应接口
export interface CreateModelCommentResponse {
comment: ModelComment; // 使用新的ModelComment类型
}
// 点赞模型评论请求接口
export interface LikeModelCommentRequest {
commentId: string;
}
// 点赞模型评论响应接口
export interface LikeModelCommentResponse {
success: boolean;
}
// 记录模型点击请求接口
export interface RecordModelClickRequest {
modelId: string;
}
// 记录模型点击响应接口
export interface RecordModelClickResponse {
success: boolean;
clickCount: number; // 更新后的总点击数
}
// 后面的都暂时不考虑
// 删除模型评论请求接口
export interface DeleteModelCommentRequest {
commentId: string;
}
// 删除模型评论响应接口
export interface DeleteModelCommentResponse {
success: boolean;
}
// 更新模型评论请求接口
export interface UpdateModelCommentRequest {
commentId: string;
content?: string; // 更新内容
}
// 更新模型评论响应接口
export interface UpdateModelCommentResponse {
success: boolean;
comment: ModelComment; // 返回更新后的评论
}
// 批量点赞模型评论请求接口
export interface BatchLikeModelCommentsRequest {
commentIds: string[]; // 评论ID列表
}
// 批量点赞模型评论响应接口
export interface BatchLikeModelCommentsResponse {
results: Array<{
commentId: string;
success: boolean;
comment?: ModelComment; // 成功时返回更新后的评论
error?: string; // 失败时的错误信息
}>;
}
// 批量删除模型评论请求接口
export interface BatchDeleteModelCommentsRequest {
commentIds: string[]; // 评论ID列表
}
// 批量删除模型评论响应接口
export interface BatchDeleteModelCommentsResponse {
results: Array<{
commentId: string;
success: boolean;
error?: string; // 失败时的错误信息
}>;
}
// 批量更新模型评论请求接口
export interface BatchUpdateModelCommentsRequest {
updates: Array<{
commentId: string;
content?: string; // 更新内容
rating?: number; // 更新评分
}>;
}
// 批量更新模型评论响应接口
export interface BatchUpdateModelCommentsResponse {
results: Array<{
commentId: string;
success: boolean;
comment?: ModelComment; // 成功时返回更新后的评论
error?: string; // 失败时的错误信息
}>;
}