Krishya | 7ec1dd0 | 2025-04-19 15:29:03 +0800 | [diff] [blame^] | 1 | import axios from 'axios'; |
| 2 | |
| 3 | const API_BASE = process.env.REACT_APP_API_BASE; |
| 4 | |
| 5 | // 获取帖子详情 |
| 6 | export const getPostDetail = async (postId) => { |
| 7 | const response = await axios.get(`${API_BASE}/echo/forum/posts/${postId}/getPost`); |
| 8 | return response.data; |
| 9 | }; |
| 10 | |
| 11 | // 获取帖子评论 |
| 12 | export const getPostComments = async (postId) => { |
| 13 | const response = await axios.get(`${API_BASE}/echo/forum/posts/${postId}/getAllComments`); |
| 14 | return response.data; |
| 15 | }; |
| 16 | |
| 17 | // 点赞帖子 |
| 18 | export const likePost = async (postId) => { |
| 19 | const response = await axios.post(`${API_BASE}/echo/forum/posts/${postId}/like`); |
| 20 | return response.data; |
| 21 | }; |
| 22 | |
| 23 | // 取消点赞帖子 |
| 24 | export const unlikePost = async (postId) => { |
| 25 | const response = await axios.delete(`${API_BASE}/echo/forum/posts/${postId}/unlike`); |
| 26 | return response.data; |
| 27 | }; |
| 28 | |
| 29 | // 添加评论 |
| 30 | export 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 | // 回复评论 |
| 36 | export 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 | // 点赞评论 |
| 42 | export const likeComment = async (commentId) => { |
| 43 | const response = await axios.post(`${API_BASE}/echo/forum/comments/${commentId}/like`); |
| 44 | return response.data; |
| 45 | }; |
| 46 | |
| 47 | // 取消点赞评论 |
| 48 | export const unlikeComment = async (commentId) => { |
| 49 | const response = await axios.delete(`${API_BASE}/echo/forum/comments/${commentId}/unlike`); |
| 50 | return response.data; |
| 51 | }; |
| 52 | |
| 53 | // 获取用户信息 |
| 54 | export const getUserInfo = async (userId) => { |
| 55 | const response = await axios.get(`${API_BASE}/user/${userId}/info`); |
| 56 | return response.data; |
| 57 | }; |