feat(image): 新建 knowai-core:1.0.0 镜像并完成推送
Some checks reported errors
continuous-integration/drone/push Build was killed

- 搭建 api、auth、utils 等逻辑模块
- 通过 tsc、eslint、vitest 测试验证

BREAKING CHANGE: 新镜像分支
This commit is contained in:
tobegold574
2025-11-10 20:20:25 +08:00
commit 6a81b7bb13
73 changed files with 10511 additions and 0 deletions

124
types/post/api.d.ts vendored Normal file
View File

@@ -0,0 +1,124 @@
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 DeletePostRequest {
postId: string;
}
// 删除帖子响应接口
export interface DeletePostResponse {
success: boolean;
}

41
types/post/base.d.ts vendored Normal file
View File

@@ -0,0 +1,41 @@
import type {User} from '../user/base';
import type {PostType} from './enum';
// 基础实体接口
export interface BaseEntity {
id: string; // 唯一标识符
createdAt: Date; // 创建时间
updatedAt: Date; // 更新时间
}
// 用户基础信息接口
export interface BaseUser {
user: User;
}
export interface PostComment extends BaseEntity {
authorId: string; // 作者ID
author: BaseUser; // 作者信息
content: string; // 评论内容
parentId?: string; // 父评论ID用于嵌套评论
}
// 实体内容和统计信息基础接口
export interface BaseEntityContent {
title?: string; // 标题
excerpt: string; // 摘要
tags?: string[]; // 标签数组
metadata?: Record<string, unknown>; // 元数据
stars: number; // 收藏数
likes: number; // 点赞数
comments: number; // 评论数
}
// 帖子接口
export interface Post extends BaseEntity, BaseEntityContent {
type: PostType; // 帖子类型:提问或文章
authorId: string; // 作者ID
author: BaseUser; // 作者信息
images?: string[]; // 图片数组
publishedAt?: Date; // 发布时间
}

28
types/post/enum.d.ts vendored Normal file
View File

@@ -0,0 +1,28 @@
// 排序方式枚举
export enum SortOrder {
ASC = 'asc',
DESC = 'desc'
}
// 排序字段枚举
export enum PostSortBy {
CREATED_AT = 'createdAt',
UPDATED_AT = 'updatedAt',
PUBLISHED_AT = 'publishedAt',
VIEWS = 'views',
LIKES = 'likes',
COMMENTS = 'comments'
}
// 评论排序字段枚举
export enum CommentSortBy {
CREATED_AT = 'createdAt',
LIKES = 'likes',
REPLIES = 'replies'
}
// 帖子类型枚举
export enum PostType {
QUESTION = 'question',
ARTICLE = 'article'
}

4
types/post/index.d.ts vendored Normal file
View File

@@ -0,0 +1,4 @@
// 导出帖子系统所有类型定义
export * from './base';
export * from './enum';
export * from './api';