重新提交

Change-Id: I41d894c30f6945402022f7309d52d9dfc0ff4c79
diff --git a/src/api/administer.js b/src/api/administer.js
index 5f28e45..d90bffa 100644
--- a/src/api/administer.js
+++ b/src/api/administer.js
@@ -1,10 +1,10 @@
 import axios from 'axios';
 
-const API_BASE_URL = 'http://localhost:8088'; // 替换为你的后端API基础URL
+// const API_BASE_URL = 'http://team2.10813352.xyz:8088'; // 替换为你的后端API基础URL
 
 export const getAllUsers = async () => {
   try {
-    const response = await axios.get(`${API_BASE_URL}/user/allUser`, {
+    const response = await axios.get(`/user/allUser`, {
       headers: {
         Authorization: localStorage.getItem('token')
       }
@@ -27,7 +27,7 @@
 
 export const searchUsers = async (key) => {
   try {
-    const response = await axios.get(`${API_BASE_URL}/user/searchUser`, {
+    const response = await axios.get(`/user/searchUser`, {
       params: { key },
       headers: {
         Authorization: localStorage.getItem('token')
@@ -50,7 +50,7 @@
 // 修改用户权限
 export const updateUserAuthority = async (username, authority) => {
   try {
-    const response = await axios.put(`${API_BASE_URL}/user/changeAuthority`, 
+    const response = await axios.put(`/user/changeAuthority`, 
       { 
         changeUsername: username, 
         authority: authority 
@@ -113,7 +113,7 @@
 // 修改 getAllDiscounts 和 getCurrentDiscount 方法
 export const getAllDiscounts = async () => {
   try {
-    const response = await axios.get(`${API_BASE_URL}/discount/all`, {
+    const response = await axios.get(`/discount/all`, {
       headers: {
         Authorization: localStorage.getItem('token')
       }
@@ -133,7 +133,7 @@
 
 export const getCurrentDiscount = async () => {
   try {
-    const response = await axios.get(`${API_BASE_URL}/discount/current`, {
+    const response = await axios.get(`/discount/current`, {
       headers: {
         Authorization: localStorage.getItem('token')
       }
@@ -156,7 +156,7 @@
 // 添加折扣
 export const addDiscount = async (discountData) => {
   try {
-    const response = await axios.post(`${API_BASE_URL}/discount/add`, discountData, {
+    const response = await axios.post(`/discount/add`, discountData, {
       headers: {
         Authorization: localStorage.getItem('token')
       }
@@ -176,7 +176,7 @@
 // 删除折扣
 export const deleteDiscount = async (id) => {
   try {
-    const response = await axios.delete(`${API_BASE_URL}/discount/delete/${id}`, {
+    const response = await axios.delete(`/discount/delete/${id}`, {
       headers: {
         Authorization: localStorage.getItem('token')
       }
diff --git a/src/api/administer.test.js b/src/api/administer.test.js
index beb1e11..e5e785e 100644
--- a/src/api/administer.test.js
+++ b/src/api/administer.test.js
@@ -37,7 +37,7 @@
       }
     ];
 
-    mock.onGet('http://localhost:8088/user/allUser').reply(200, {
+    mock.onGet('/user/allUser').reply(200, {
       code: 200,
       data: { data: mockUsers }
     });
@@ -47,7 +47,7 @@
   });
 
   it('should return empty array when no users', async () => {
-    mock.onGet('http://localhost:8088/user/allUser').reply(200, {
+    mock.onGet('/user/allUser').reply(200, {
       code: 200,
       data: { data: [] }
     });
@@ -57,7 +57,7 @@
   });
 
   it('should handle error when fetching users', async () => {
-    mock.onGet('http://localhost:8088/user/allUser').reply(500, {
+    mock.onGet('/user/allUser').reply(500, {
       message: 'Request failed with status code 500'
     });
 
@@ -74,7 +74,7 @@
         }
       ];
 
-      mock.onGet('http://localhost:8088/user/searchUser', { params: { key: 'user' } })
+      mock.onGet('/user/searchUser', { params: { key: 'user' } })
         .reply(200, {
           code: 200,
           data: { data: mockUsers }
@@ -92,7 +92,7 @@
         }
       ];
 
-      mock.onGet('http://localhost:8088/user/searchUser', { params: { key: '' } })
+      mock.onGet('/user/searchUser', { params: { key: '' } })
         .reply(200, {
           code: 200,
           data: { data: mockUsers }
@@ -108,7 +108,7 @@
       const username = 'user1';
       const authority = 'ADMIN';
 
-      mock.onPut('http://localhost:8088/user/changeAuthority', {
+      mock.onPut('/user/changeAuthority', {
         changeUsername: username,
         authority: authority
       }).reply(200, {
@@ -133,7 +133,7 @@
         }
       ];
 
-      mock.onGet('http://localhost:8088/discount/all').reply(200, {
+      mock.onGet('/discount/all').reply(200, {
         code: 200,
         data: { data: mockDiscounts }
       });
@@ -153,7 +153,7 @@
       endTime: '2023-05-07T23:59:59'
     };
 
-    mock.onGet('http://localhost:8088/discount/current').reply(200, {
+    mock.onGet('/discount/current').reply(200, {
       code: 200,
       data: { data: mockDiscount }
     });
@@ -163,7 +163,7 @@
   });
 
   it('should return null when no current discount', async () => {
-    mock.onGet('http://localhost:8088/discount/current').reply(200, {
+    mock.onGet('/discount/current').reply(200, {
       code: 200,
       message: '目前没有进行中的折扣',
       data: null
@@ -174,7 +174,7 @@
   });
 
   it('should handle error when fetching current discount', async () => {
-    mock.onGet('http://localhost:8088/discount/current').reply(500);
+    mock.onGet('/discount/current').reply(500);
 
     await expect(getCurrentDiscount()).rejects.toThrow();
   });
@@ -189,7 +189,7 @@
         endTime: '2023-06-07T23:59:59'
       };
 
-      mock.onPost('http://localhost:8088/discount/add', newDiscount).reply(200, {
+      mock.onPost('/discount/add', newDiscount).reply(200, {
         code: 200,
         data: { data: { id: 2, ...newDiscount } }
       });
@@ -203,7 +203,7 @@
     it('should delete discount successfully', async () => {
       const discountId = 1;
 
-      mock.onDelete(`http://localhost:8088/discount/delete/${discountId}`).reply(200, {
+      mock.onDelete(`/discount/delete/${discountId}`).reply(200, {
         code: 200,
         message: '删除成功'
       });
diff --git a/src/api/auth.js b/src/api/auth.js
index c094a44..a779af2 100644
--- a/src/api/auth.js
+++ b/src/api/auth.js
@@ -3,7 +3,7 @@
 

 // 创建并导出 axios 实例

 export const api = axios.create({

-  baseURL: 'http://localhost:8088',

+  baseURL: 'http://team2.10813352.xyz:8088',

   timeout: 5000,

 });

 

diff --git a/src/api/recommend.js b/src/api/recommend.js
new file mode 100644
index 0000000..13c9f94
--- /dev/null
+++ b/src/api/recommend.js
@@ -0,0 +1,30 @@
+// src/api/recommend.js
+import { api } from './auth';
+
+export const getRecommendations = async (limit = 5) => {
+  try {
+    const response = await api.get('/recommend/for-user', {
+      params: { limit }
+    });
+    return response.data;
+  } catch (error) {
+    console.error('获取推荐失败:', error);
+    throw error;
+  }
+};
+
+export const markRecommendationShown = async (torrentId) => {
+  try {
+    await api.post(`/recommend/mark-shown/${torrentId}`);
+  } catch (error) {
+    console.error('标记推荐为已显示失败:', error);
+  }
+};
+
+export const markRecommendationClicked = async (torrentId) => {
+  try {
+    await api.post(`/recommend/mark-clicked/${torrentId}`);
+  } catch (error) {
+    console.error('标记推荐为已点击失败:', error);
+  }
+};
\ No newline at end of file