diff --git a/src/api/CommentAPI.ts b/src/api/CommentAPI.ts index 120423d..d72d947 100644 --- a/src/api/CommentAPI.ts +++ b/src/api/CommentAPI.ts @@ -1,27 +1,17 @@ -import { - axios, - CaptchaData, - Comment, - CommentPage, - CommentReply, - CommentReplyPage, - CommentReplyView, - CommentView, - PageResult -} from "~/index"; +import { axios, CaptchaData, Comment, CommentReply, Page, PageResult } from "~/index"; const BASE_URI = "/comment"; -async function page(commentPage: CommentPage): Promise> { - return axios.post(`${BASE_URI}/list`, commentPage); +async function page(page: Page): Promise> { + return axios.post(`${BASE_URI}/list`, page); } async function create(captchaData: CaptchaData): Promise { return axios.post(`${BASE_URI}/create`, captchaData); } -async function pageReply(commentReplyPage: CommentReplyPage): Promise> { - return axios.post(`${BASE_URI}/reply/list`, commentReplyPage); +async function pageReply(page: Page): Promise> { + return axios.post(`${BASE_URI}/reply/list`, page); } async function createReply(captchaData: CaptchaData): Promise { diff --git a/src/types/Comment.ts b/src/types/Comment.ts index 5a218c2..659721c 100644 --- a/src/types/Comment.ts +++ b/src/types/Comment.ts @@ -3,57 +3,47 @@ import { UserView } from "./User"; /** 评论 */ export type Comment = { - bizType: CommentBizType; - bizId: number; + bizType?: CommentBizType; + bizId?: number; userId?: number; nick?: string; - content: string; -} & Model + content?: string; -/** 评论视图 */ -export type CommentView = { /** 所属用户 */ user?: UserView; /** 回复列表 */ - replies: CommentReplyView[]; + replies?: CommentReply[]; /** 回复分页 */ - repliesPage: CommentReplyPage; + repliesPage?: Page; /** 用于绑定组件当前页下标 */ - repliesCurrent: number; + repliesCurrent?: number; /** 回复数量 */ - repliesLength: number; + repliesLength?: number; /** 关联文章 */ article?: object; /** 关联 Git 仓库 */ repository?: object; -} & Comment; +} & Model export type CommentReply = { replyId?: number; - commentId: number; + commentId?: number; senderId?: number; senderNick?: string; receiverId?: number; receiverNick?: string; - content: string; -} & Model; + content?: string; -export type CommentReplyView = { - comment: CommentView; + comment?: Comment; sender?: UserView; receiver?: UserView; -} & CommentReply; - -export type CommentPage = { - bizType?: CommentBizType; - bizId?: number; -} & Page; +} & Model; export enum CommentReplyBizType { @@ -64,11 +54,6 @@ export enum CommentReplyBizType { RECEIVER = "RECEIVER" } -export type CommentReplyPage = { - bizType: CommentReplyBizType - bizId?: number -} & Page; - export enum CommentBizType { ARTICLE = "ARTICLE",