公告用户前端以及管理员
Change-Id: I3ea4a7f62ae91ef97734d6d673cce28855d10eeb
diff --git a/src/api/activity.js b/src/api/activity.js
new file mode 100644
index 0000000..8d9b24f
--- /dev/null
+++ b/src/api/activity.js
@@ -0,0 +1,48 @@
+import axios from 'axios';
+
+const BASE_URL = 'http://localhost:8080/activity';
+
+// 获取所有 is_show == 0 的活动预览(只含标题和图片)
+export const getActivityPreviews = () => {
+ return axios.get(`${BASE_URL}/preview`);
+};
+
+// 获取所有 is_show == 0 的完整活动信息
+export const getFullActivities = () => {
+ return axios.get(`${BASE_URL}/full`);
+};
+
+// 创建新的活动公告(使用 FormData 传递)
+export const createActivity = (formData) => {
+ return axios.post(`${BASE_URL}/create`, formData, {
+ headers: {
+ 'Content-Type': 'multipart/form-data',
+ },
+ });
+};
+
+// 删除活动公告(通过 ID)
+export const deleteActivity = (id) => {
+ return axios.delete(`${BASE_URL}/delete/${id}`);
+};
+
+// 获取所有活动(无论展示状态)
+export const getAllActivities = () => {
+ return axios.get(`${BASE_URL}/all`);
+};
+
+// 修改活动公告(使用 FormData 传递)
+export const updateActivity = (formData) => {
+ return axios.put(`${BASE_URL}/update`, formData, {
+ headers: {
+ 'Content-Type': 'multipart/form-data',
+ },
+ });
+};
+
+// 根据标题搜索活动
+export const searchActivitiesByTitle = (title) => {
+ return axios.get(`${BASE_URL}/search`, {
+ params: { title },
+ });
+};