修改论坛、促销、登录,增加测试
Change-Id: I71883fc1da46a94db47f90a4cd61474c274a5b2c
diff --git a/src/pages/Forum/posts-detail/api.js b/src/pages/Forum/posts-detail/api.js
index d05f148..27c3a18 100644
--- a/src/pages/Forum/posts-detail/api.js
+++ b/src/pages/Forum/posts-detail/api.js
@@ -2,22 +2,23 @@
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`);
+export const getPostDetail = async (post_id) => {
+ const response = await axios.get(`${API_BASE}/echo/forum/posts/${post_id}/getPost`);
return response.data;
};
// 获取帖子评论
-export const getPostComments = async (postId) => {
- const response = await axios.get(`${API_BASE}/echo/forum/posts/${postId}/getAllComments`);
+export const getPostComments = async (post_id) => {
+ const response = await axios.get(`${API_BASE}/echo/forum/posts/${post_id}/getAllComments`);
return response.data;
};
// 点赞帖子
-export const likePost = async (postId, userId) => {
+export const likePost = async (post_id, userId) => {
try {
- const response = await axios.post(`${API_BASE}/echo/forum/posts/${postId}/like`, {
+ const response = await axios.post(`${API_BASE}/echo/forum/posts/${post_id}/like`, {
user_id: userId, // 用户 ID
});
return response.data;
@@ -27,15 +28,15 @@
};
// 取消点赞帖子
-export const unlikePost = async (postId) => {
- const response = await axios.delete(`${API_BASE}/echo/forum/posts/${postId}/unlike`);
+export const unlikePost = async (post_id) => {
+ const response = await axios.delete(`${API_BASE}/echo/forum/posts/${post_id}/unlike`);
return response.data;
};
// 添加评论
-export const addCommentToPost = async (postId, userId, content, isAnonymous, comCommentId = null) => {
+export const addCommentToPost = async (post_id, userId, content, isAnonymous, comCommentId = null) => {
try {
- const response = await axios.post(`${API_BASE}/echo/forum/posts/${postId}/comments`, {
+ const response = await axios.post(`${API_BASE}/echo/forum/posts/${post_id}/comments`, {
content,
user_id: userId,
is_anonymous: isAnonymous,
@@ -60,9 +61,9 @@
};
// 收藏帖子
-export const collectPost = async (postId, userId, action) => {
+export const collectPost = async (post_id, userId, action) => {
try {
- const response = await axios.post(`${API_BASE}/echo/forum/posts/${postId}/collect`, {
+ const response = await axios.post(`${API_BASE}/echo/forum/posts/${post_id}/collect`, {
user_id: userId,
action: action, // "collect" 或 "cancel"
});
@@ -72,6 +73,14 @@
}
};
+// // 取消收藏帖子
+// export const uncollectPost = async (post_id, userId) => {
+// const response = await axios.post(`${API_BASE}/echo/forum/posts/${post_id}/uncollect`, {
+// user_id: userId, // 用户 ID
+// });
+// return response.data;
+// };
+
// 获取用户信息
export const getUserInfo = async (userId) => {
const response = await axios.get(`${API_BASE}/user/${userId}/info`);