blob: 8d9b24fa7c16c7e1ee07e618cbf2df19451b9866 [file] [log] [blame]
ym923bfa214f2025-06-09 18:10:32 +08001import axios from 'axios';
2
3const BASE_URL = 'http://localhost:8080/activity';
4
5// 获取所有 is_show == 0 的活动预览(只含标题和图片)
6export const getActivityPreviews = () => {
7 return axios.get(`${BASE_URL}/preview`);
8};
9
10// 获取所有 is_show == 0 的完整活动信息
11export const getFullActivities = () => {
12 return axios.get(`${BASE_URL}/full`);
13};
14
15// 创建新的活动公告(使用 FormData 传递)
16export const createActivity = (formData) => {
17 return axios.post(`${BASE_URL}/create`, formData, {
18 headers: {
19 'Content-Type': 'multipart/form-data',
20 },
21 });
22};
23
24// 删除活动公告(通过 ID)
25export const deleteActivity = (id) => {
26 return axios.delete(`${BASE_URL}/delete/${id}`);
27};
28
29// 获取所有活动(无论展示状态)
30export const getAllActivities = () => {
31 return axios.get(`${BASE_URL}/all`);
32};
33
34// 修改活动公告(使用 FormData 传递)
35export const updateActivity = (formData) => {
36 return axios.put(`${BASE_URL}/update`, formData, {
37 headers: {
38 'Content-Type': 'multipart/form-data',
39 },
40 });
41};
42
43// 根据标题搜索活动
44export const searchActivitiesByTitle = (title) => {
45 return axios.get(`${BASE_URL}/search`, {
46 params: { title },
47 });
48};