Files
rating/api/pk.js
2026-06-15 23:14:05 +08:00

88 lines
1.7 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { request } from "@/utils/request.js";
// 获取随机一组PK主题
export const fetchRandomTopicList = async () => {
return request({
url: "/api/rating/pk/random",
method: "GET",
});
};
/**
* 用户投票
* @param { pkId, itemId }
*/
export const vote = async (data) => {
return request({
url: "/api/rating/pk/vote",
method: "POST",
data,
});
};
/**
* 获取PK 评论列表
* @param { pkId: string, page: number, orderBy: string }
* @param { orderBy: string } 排序字段,可选值:'hot' | 'new',
*/
export const fetchCommentList = async (data) => {
return request({
url: "/api/rating/pk/comment/list",
method: "GET",
data,
});
};
/**
* 获取PK 评论回复
* @param { pkId: string, rootCommentId: string, page: number }
*/
export const fetchCommentReplyList = async (data) => {
return request({
url: "/api/rating/pk/comment/replies",
method: "GET",
data,
});
};
/**
* 发布PK 评论
* @param { pkId: string, content: string, parentCommentId?: string, replyToCommentId?: string }
* @param { parentCommentId?: string } 父评论ID回复时必填
* @param { replyToCommentId?: string } 回复的评论ID回复时必填
*/
export const publishComment = async (data) => {
return request({
url: "/api/rating/pk/comment",
method: "POST",
data,
});
};
/**
* PK 评论 点赞
* @param { commentId: string }
*/
export const likeComment = async (data) => {
return request({
url: "/api/rating/pk/comment/like",
method: "POST",
data,
});
};
/**
* 获取用户 pk 列表
* @param { page: number }
*/
export const fetchUserPkList = async (data) => {
return request({
url: "/api/rating/personal/pk/list",
method: "GET",
data,
});
};