blob: 8ac3e0302abbab6edc2f267995ec7adf844044ee [file] [log] [blame]
ym9232a70a622025-06-09 20:12:13 +08001import axios from 'axios';
2
3const BASE_URL = 'http://localhost:8080/complain';
4
5// 创建投诉
6export const createComplain = async (complainData) => {
7 try {
8 const response = await axios.post(`${BASE_URL}/create`, complainData);
9 return response.data;
10 } catch (error) {
11 console.error('创建投诉失败:', error);
12 throw error;
13 }
14};
15
16// 删除投诉(根据 complainid)
17export const deleteComplain = async (complainid) => {
18 try {
19 const response = await axios.delete(`${BASE_URL}/delete/${complainid}`);
20 return response.data;
21 } catch (error) {
22 console.error('删除投诉失败:', error);
23 throw error;
24 }
25};
26
27// 更新投诉
28export const updateComplain = async (complainData) => {
29 try {
30 const response = await axios.put(`${BASE_URL}/update`, complainData);
31 return response.data;
32 } catch (error) {
33 console.error('更新投诉失败:', error);
34 throw error;
35 }
36};
37
38// 获取某个被投诉用户的所有投诉记录(根据 duser)
39export const getComplainsByTargetUser = async (duser) => {
40 try {
41 const response = await axios.get(`${BASE_URL}/target/${duser}`);
42 return response.data;
43 } catch (error) {
44 console.error('获取被投诉用户的投诉记录失败:', error);
45 throw error;
46 }
47};
48
49// 获取某个投诉发起者的所有投诉记录(根据 puse)
50export const getComplainsByPostingUser = async (puse) => {
51 try {
52 const response = await axios.get(`${BASE_URL}/from/${puse}`);
53 return response.data;
54 } catch (error) {
55 console.error('获取用户提交的投诉记录失败:', error);
56 throw error;
57 }
58};
59
60// ✅ 获取所有投诉记录
61export const getAllComplains = async () => {
62 try {
63 const response = await axios.get(`${BASE_URL}/all`);
64 return response.data;
65 } catch (error) {
66 console.error('获取所有投诉记录失败:', error);
67 throw error;
68 }
69};
70
71// ✅ 根据投诉 ID 获取详情(包含投诉用户、被投诉用户、种子号等)
72export const getComplainDetailById = async (complainid) => {
73 try {
74 const response = await axios.get(`${BASE_URL}/detail/${complainid}`);
75 return response.data;
76 } catch (error) {
77 console.error('获取投诉详情失败:', error);
78 throw error;
79 }
80};