刘嘉昕 | 9cdeca2 | 2025-06-03 16:54:30 +0800 | [diff] [blame] | 1 | import axios from 'axios'; |
| 2 | |
| 3 | const BASE_URL = 'http://localhost:8080/friends'; |
| 4 | |
| 5 | // 添加好友 |
| 6 | export const addFriend = (friendData) => { |
| 7 | return axios.post(`${BASE_URL}/add`, friendData); |
| 8 | }; |
| 9 | |
| 10 | // ✅ 删除好友(通过 friend1 和 friend2 双向删除) |
| 11 | export const deleteFriend = (friend1, friend2) => { |
| 12 | return axios.delete(`${BASE_URL}/delete`, { |
| 13 | params: { friend1, friend2 } |
| 14 | }); |
| 15 | }; |
| 16 | |
| 17 | // 查询某个用户的所有好友(friend1 或 friend2) |
| 18 | export const getFriendsByUserId = (userid) => { |
| 19 | return axios.get(`${BASE_URL}/list/${userid}`); |
| 20 | }; |