blob: 924cba9aef37ceda9371772b7357a1554f49f30a [file] [log] [blame]
import axios from 'axios';
const API_BASE = process.env.REACT_APP_API_BASE;
// 获取帖子详情
export const getPostDetail = async (postId) => {
const response = await axios.get(`${API_BASE}/echo/forum/posts/${postId}/getPost`);
return response.data;
};
// 获取帖子评论
export const getPostComments = async (postId) => {
const response = await axios.get(`${API_BASE}/echo/forum/posts/${postId}/getAllComments`);
return response.data;
};
// 点赞帖子
export const likePost = async (postId) => {
const response = await axios.post(`${API_BASE}/echo/forum/posts/${postId}/like`);
return response.data;
};
// 取消点赞帖子
export const unlikePost = async (postId) => {
const response = await axios.delete(`${API_BASE}/echo/forum/posts/${postId}/unlike`);
return response.data;
};
// 添加评论
export const addCommentToPost = async (postId, content) => {
const response = await axios.post(`${API_BASE}/echo/forum/posts/${postId}/comments`, { content });
return response.data;
};
// 回复评论
export const replyToComment = async (commentId, replyContent) => {
const response = await axios.post(`${API_BASE}/echo/forum/comments/${commentId}/reply`, { content: replyContent });
return response.data;
};
// 点赞评论
export const likeComment = async (commentId) => {
const response = await axios.post(`${API_BASE}/echo/forum/comments/${commentId}/like`);
return response.data;
};
// 取消点赞评论
export const unlikeComment = async (commentId) => {
const response = await axios.delete(`${API_BASE}/echo/forum/comments/${commentId}/unlike`);
return response.data;
};
// 获取用户信息
export const getUserInfo = async (userId) => {
const response = await axios.get(`${API_BASE}/user/${userId}/info`);
return response.data;
};