合并

Change-Id: I19ca58c58a513cba20c162c9ed7cbab90e060bf6
diff --git a/src/api/helpPost.js b/src/api/helpPost.js
index 426e92b..4813aa3 100644
--- a/src/api/helpPost.js
+++ b/src/api/helpPost.js
@@ -1,12 +1,19 @@
 // src/api/helpPost.js

 import { api } from './auth'; // 复用已有的axios实例

 

-export const createPost = (title, content, authorId) => {

-  return api.post('/help/posts', { 

-    title, 

-    content, 

-    authorId 

-  });

+export const createPost = (title, content, authorId, selectedImage) => {

+  // 创建 FormData 对象

+  const formData = new FormData();

+  formData.append('title', title);

+  formData.append('content', content);

+  formData.append('authorId', authorId);

+  

+  // 如果有图片,添加到 FormData

+  if (selectedImage) {

+    formData.append('image', selectedImage);

+  }

+

+  return api.post('/help/posts', formData);

 };

 

 export const getPosts = (page = 1, size = 5) => {

@@ -19,10 +26,28 @@
   return api.get(`/help/posts/${postId}`);

 };

 

-export const likePost = (postId) => {

-  return api.post(`/help/posts/${postId}/like`);

+export const likePost = (postId, data) => {

+  return api.post(`/help/posts/${postId}/like`, null, {

+    params: data

+  });

 };

 

 export const addPostComment = (postId, commentData) => {

-  return api.post(`/help/posts/${postId}/comments`, commentData);

+  // 创建FormData对象来处理文件上传

+  const formData = new FormData();

+  formData.append('authorId', commentData.authorId);

+  formData.append('content', commentData.content);

+  

+  // 如果有图片,添加到formData

+  if (commentData.commentImage) {

+    formData.append('image', commentData.commentImage);

+  }

+

+  return api.post(`/help/posts/${postId}/comments`, formData);

+};

+

+export const deletePost = (postId, authorId) => {

+  return api.delete(`/help/posts/${postId}`, {

+    params: { authorId }

+  });

 };
\ No newline at end of file