blob: 924cba9aef37ceda9371772b7357a1554f49f30a [file] [log] [blame]
Krishya7ec1dd02025-04-19 15:29:03 +08001import axios from 'axios';
2
3const API_BASE = process.env.REACT_APP_API_BASE;
4
5// 获取帖子详情
6export const getPostDetail = async (postId) => {
7 const response = await axios.get(`${API_BASE}/echo/forum/posts/${postId}/getPost`);
8 return response.data;
9};
10
11// 获取帖子评论
12export const getPostComments = async (postId) => {
13 const response = await axios.get(`${API_BASE}/echo/forum/posts/${postId}/getAllComments`);
14 return response.data;
15};
16
17// 点赞帖子
18export const likePost = async (postId) => {
19 const response = await axios.post(`${API_BASE}/echo/forum/posts/${postId}/like`);
20 return response.data;
21};
22
23// 取消点赞帖子
24export const unlikePost = async (postId) => {
25 const response = await axios.delete(`${API_BASE}/echo/forum/posts/${postId}/unlike`);
26 return response.data;
27};
28
29// 添加评论
30export const addCommentToPost = async (postId, content) => {
31 const response = await axios.post(`${API_BASE}/echo/forum/posts/${postId}/comments`, { content });
32 return response.data;
33};
34
35// 回复评论
36export const replyToComment = async (commentId, replyContent) => {
37 const response = await axios.post(`${API_BASE}/echo/forum/comments/${commentId}/reply`, { content: replyContent });
38 return response.data;
39};
40
41// 点赞评论
42export const likeComment = async (commentId) => {
43 const response = await axios.post(`${API_BASE}/echo/forum/comments/${commentId}/like`);
44 return response.data;
45};
46
47// 取消点赞评论
48export const unlikeComment = async (commentId) => {
49 const response = await axios.delete(`${API_BASE}/echo/forum/comments/${commentId}/unlike`);
50 return response.data;
51};
52
53// 获取用户信息
54export const getUserInfo = async (userId) => {
55 const response = await axios.get(`${API_BASE}/user/${userId}/info`);
56 return response.data;
57};