Akane1217 | 65b61a7 | 2025-05-17 13:52:25 +0800 | [diff] [blame^] | 1 | // src/api/helpPost.js
|
| 2 | import { api } from './auth'; // 复用已有的axios实例
|
| 3 |
|
| 4 | export const createPost = (title, content, authorId) => {
|
| 5 | return api.post('/help/posts', {
|
| 6 | title,
|
| 7 | content,
|
| 8 | authorId
|
| 9 | });
|
| 10 | };
|
| 11 |
|
| 12 | export const getPosts = (page = 1, size = 5) => {
|
| 13 | return api.get('/help/posts', {
|
| 14 | params: { page, size }
|
| 15 | });
|
| 16 | };
|
| 17 |
|
| 18 | export const getPostDetail = (postId) => {
|
| 19 | return api.get(`/help/posts/${postId}`);
|
| 20 | };
|
| 21 |
|
| 22 | export const likePost = (postId) => {
|
| 23 | return api.post(`/help/posts/${postId}/like`);
|
| 24 | };
|
| 25 |
|
| 26 | export const addPostComment = (postId, commentData) => {
|
| 27 | return api.post(`/help/posts/${postId}/comments`, commentData);
|
| 28 | }; |