fix Comment Page

This commit is contained in:
Timi
2026-01-15 15:22:07 +08:00
parent 5feb987af6
commit 8e9ba23f72
2 changed files with 17 additions and 42 deletions

View File

@@ -1,27 +1,17 @@
import { import { axios, CaptchaData, Comment, CommentReply, Page, PageResult } from "~/index";
axios,
CaptchaData,
Comment,
CommentPage,
CommentReply,
CommentReplyPage,
CommentReplyView,
CommentView,
PageResult
} from "~/index";
const BASE_URI = "/comment"; const BASE_URI = "/comment";
async function page(commentPage: CommentPage): Promise<PageResult<CommentView>> { async function page(page: Page<Comment>): Promise<PageResult<Comment>> {
return axios.post(`${BASE_URI}/list`, commentPage); return axios.post(`${BASE_URI}/list`, page);
} }
async function create(captchaData: CaptchaData<Comment>): Promise<void> { async function create(captchaData: CaptchaData<Comment>): Promise<void> {
return axios.post(`${BASE_URI}/create`, captchaData); return axios.post(`${BASE_URI}/create`, captchaData);
} }
async function pageReply(commentReplyPage: CommentReplyPage): Promise<PageResult<CommentReplyView>> { async function pageReply(page: Page<CommentReply>): Promise<PageResult<CommentReply>> {
return axios.post(`${BASE_URI}/reply/list`, commentReplyPage); return axios.post(`${BASE_URI}/reply/list`, page);
} }
async function createReply(captchaData: CaptchaData<CommentReply>): Promise<void> { async function createReply(captchaData: CaptchaData<CommentReply>): Promise<void> {

View File

@@ -3,57 +3,47 @@ import { UserView } from "./User";
/** 评论 */ /** 评论 */
export type Comment = { export type Comment = {
bizType: CommentBizType; bizType?: CommentBizType;
bizId: number; bizId?: number;
userId?: number; userId?: number;
nick?: string; nick?: string;
content: string; content?: string;
} & Model
/** 评论视图 */
export type CommentView = {
/** 所属用户 */ /** 所属用户 */
user?: UserView; user?: UserView;
/** 回复列表 */ /** 回复列表 */
replies: CommentReplyView[]; replies?: CommentReply[];
/** 回复分页 */ /** 回复分页 */
repliesPage: CommentReplyPage; repliesPage?: Page<CommentReply>;
/** 用于绑定组件当前页下标 */ /** 用于绑定组件当前页下标 */
repliesCurrent: number; repliesCurrent?: number;
/** 回复数量 */ /** 回复数量 */
repliesLength: number; repliesLength?: number;
/** 关联文章 */ /** 关联文章 */
article?: object; article?: object;
/** 关联 Git 仓库 */ /** 关联 Git 仓库 */
repository?: object; repository?: object;
} & Comment; } & Model
export type CommentReply = { export type CommentReply = {
replyId?: number; replyId?: number;
commentId: number; commentId?: number;
senderId?: number; senderId?: number;
senderNick?: string; senderNick?: string;
receiverId?: number; receiverId?: number;
receiverNick?: string; receiverNick?: string;
content: string; content?: string;
} & Model;
export type CommentReplyView = { comment?: Comment;
comment: CommentView;
sender?: UserView; sender?: UserView;
receiver?: UserView; receiver?: UserView;
} & CommentReply; } & Model;
export type CommentPage = {
bizType?: CommentBizType;
bizId?: number;
} & Page<Comment>;
export enum CommentReplyBizType { export enum CommentReplyBizType {
@@ -64,11 +54,6 @@ export enum CommentReplyBizType {
RECEIVER = "RECEIVER" RECEIVER = "RECEIVER"
} }
export type CommentReplyPage = {
bizType: CommentReplyBizType
bizId?: number
} & Page<Comment>;
export enum CommentBizType { export enum CommentBizType {
ARTICLE = "ARTICLE", ARTICLE = "ARTICLE",