diff --git a/e2e-tests/auth-test.spec.ts b/e2e-tests/auth-test.spec.ts index d105268..966fde2 100644 --- a/e2e-tests/auth-test.spec.ts +++ b/e2e-tests/auth-test.spec.ts @@ -5,7 +5,7 @@ test.describe('认证和授权测试', () => { let userId: number; test.beforeAll(async ({ request }) => { - const response = await request.post('http://localhost:8080/api/auth/login', { + const response = await request.post('http://localhost:8080/api/admin/auth/login', { headers: { 'Content-Type': 'application/json' }, @@ -28,7 +28,7 @@ test.describe('认证和授权测试', () => { }); await test.step('发送登录请求', async () => { - const response = await page.request.post('http://localhost:8080/api/auth/login', { + const response = await page.request.post('http://localhost:8080/api/admin/auth/login', { headers: { 'Content-Type': 'application/json' }, @@ -78,7 +78,7 @@ test.describe('认证和授权测试', () => { }); await test.step('查询指定用户信息', async () => { - const response = await page.request.get(`http://localhost:8080/api/users/${userId}`, { + const response = await page.request.get(`http://localhost:8080/api/admin/users/${userId}`, { headers: { 'Authorization': `Bearer ${authToken}` } @@ -98,10 +98,10 @@ test.describe('认证和授权测试', () => { test('权限验证测试', async ({ page }) => { await test.step('测试访问受保护的API', async () => { const protectedEndpoints = [ - '/api/users', - '/api/roles', - '/api/menus', - '/api/config' + '/api/admin/users', + '/api/admin/roles', + '/api/admin/menus', + '/api/admin/config' ]; for (const endpoint of protectedEndpoints) { diff --git a/e2e-tests/config-management.spec.ts b/e2e-tests/config-management.spec.ts index 670676a..acfad69 100644 --- a/e2e-tests/config-management.spec.ts +++ b/e2e-tests/config-management.spec.ts @@ -4,7 +4,7 @@ test.describe('参数配置功能测试', () => { let authToken: string; test.beforeAll(async ({ request }) => { - const response = await request.post('http://localhost:8080/api/auth/login', { + const response = await request.post('http://localhost:8080/api/admin/auth/login', { headers: { 'Content-Type': 'application/json' }, diff --git a/e2e-tests/dict-management.spec.ts b/e2e-tests/dict-management.spec.ts index 30c403d..0993362 100644 --- a/e2e-tests/dict-management.spec.ts +++ b/e2e-tests/dict-management.spec.ts @@ -4,7 +4,7 @@ test.describe('字典管理功能测试', () => { let authToken: string; test.beforeAll(async ({ request }) => { - const response = await request.post('http://localhost:8080/api/auth/login', { + const response = await request.post('http://localhost:8080/api/admin/auth/login', { headers: { 'Content-Type': 'application/json' }, diff --git a/e2e-tests/global-setup.ts b/e2e-tests/global-setup.ts index 995974a..69ac8c9 100644 --- a/e2e-tests/global-setup.ts +++ b/e2e-tests/global-setup.ts @@ -269,7 +269,7 @@ async function verifyAllServices(): Promise { console.log(' 验证网关到后端的连通性...'); try { - const response = await fetch('http://localhost:8080/api/auth/login', { + const response = await fetch('http://localhost:8080/api/admin/auth/login', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ username: 'admin', password: 'Test@123' }), @@ -316,7 +316,7 @@ async function waitForBackendReady(): Promise { console.log(`✅ 后端服务健康检查通过 (尝试 ${i + 1}/${maxRetries})`); try { - const loginTest = await fetch('http://localhost:8084/api/auth/login', { + const loginTest = await fetch('http://localhost:8084/api/admin/auth/login', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ username: 'admin', password: 'Test@123' }), @@ -364,7 +364,7 @@ async function waitForGatewayReady(): Promise { console.log(`✅ 网关服务健康检查通过 (尝试 ${i + 1}/${maxRetries})`); try { - const loginTest = await fetch('http://localhost:8080/api/auth/login', { + const loginTest = await fetch('http://localhost:8080/api/admin/auth/login', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ username: 'admin', password: 'Test@123' }), @@ -425,7 +425,7 @@ async function waitForFrontendReady(): Promise { async function cleanupTestData(): Promise { try { // 登录获取token(通过网关) - const loginResponse = await fetch('http://localhost:8080/api/auth/login', { + const loginResponse = await fetch('http://localhost:8080/api/admin/auth/login', { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -458,7 +458,7 @@ async function cleanupTestData(): Promise { for (const user of users) { if (user.id > 10) { try { - await fetch(`http://localhost:8080/api/users/${user.id}`, { + await fetch(`http://localhost:8080/api/admin/users/${user.id}`, { method: 'DELETE', headers: { 'Authorization': `Bearer ${token}` @@ -486,7 +486,7 @@ async function cleanupTestData(): Promise { for (const role of roles) { if (role.id > 4) { try { - await fetch(`http://localhost:8080/api/roles/${role.id}`, { + await fetch(`http://localhost:8080/api/admin/roles/${role.id}`, { method: 'DELETE', headers: { 'Authorization': `Bearer ${token}` diff --git a/e2e-tests/journeys/admin-complete-workflow.spec.ts b/e2e-tests/journeys/admin-complete-workflow.spec.ts index 579fd88..c59809b 100644 --- a/e2e-tests/journeys/admin-complete-workflow.spec.ts +++ b/e2e-tests/journeys/admin-complete-workflow.spec.ts @@ -50,7 +50,7 @@ test.describe('管理员完整工作流', () => { await test.step('提交表单', async () => { const [response] = await Promise.all([ page.waitForResponse(resp => - resp.url().includes('/api/roles') && resp.request().method() === 'POST', + resp.url().includes('/api/admin/roles') && resp.request().method() === 'POST', { timeout: 10000 } ).catch(() => null), page.locator('.el-dialog button:has-text("确定")').click() diff --git a/e2e-tests/journeys/user-permission-boundary.spec.ts b/e2e-tests/journeys/user-permission-boundary.spec.ts index 6a14652..b3731dc 100644 --- a/e2e-tests/journeys/user-permission-boundary.spec.ts +++ b/e2e-tests/journeys/user-permission-boundary.spec.ts @@ -112,7 +112,7 @@ test.describe('用户权限边界验证', () => { }); await test.step('尝试访问受限API', async () => { - const response = await page.request.get('/api/users?page=0&size=10'); + const response = await page.request.get('/api/admin/users?page=0&size=10'); expect([200, 401, 403]).toContain(response.status()); }); }); diff --git a/e2e-tests/menu-management.spec.ts b/e2e-tests/menu-management.spec.ts index 0d09e64..678f206 100644 --- a/e2e-tests/menu-management.spec.ts +++ b/e2e-tests/menu-management.spec.ts @@ -4,7 +4,7 @@ test.describe('菜单管理功能测试', () => { let authToken: string; test.beforeAll(async ({ request }) => { - const response = await request.post('http://localhost:8080/api/auth/login', { + const response = await request.post('http://localhost:8080/api/admin/auth/login', { headers: { 'Content-Type': 'application/json' }, diff --git a/e2e-tests/utils/api-client.ts b/e2e-tests/utils/api-client.ts index 17085c7..3df333b 100644 --- a/e2e-tests/utils/api-client.ts +++ b/e2e-tests/utils/api-client.ts @@ -10,7 +10,7 @@ export class ApiClient { } async login(username: string, password: string): Promise<{ token: string; userId: number }> { - const response = await this.request.post(`${this.baseURL}/api/auth/login`, { + const response = await this.request.post(`${this.baseURL}/api/admin/auth/login`, { data: { username, password, @@ -29,7 +29,7 @@ export class ApiClient { } async logout(token: string): Promise { - await this.request.post(`${this.baseURL}/api/auth/logout`, { + await this.request.post(`${this.baseURL}/api/admin/auth/logout`, { headers: { Authorization: `Bearer ${token}`, }, @@ -37,7 +37,7 @@ export class ApiClient { } async getUsers(token: string): Promise { - const response = await this.request.get(`${this.baseURL}/api/users`, { + const response = await this.request.get(`${this.baseURL}/api/admin/users`, { headers: { Authorization: `Bearer ${token}`, }, @@ -51,7 +51,7 @@ export class ApiClient { } async createUser(token: string, userData: any): Promise { - const response = await this.request.post(`${this.baseURL}/api/users`, { + const response = await this.request.post(`${this.baseURL}/api/admin/users`, { headers: { Authorization: `Bearer ${token}`, }, @@ -66,7 +66,7 @@ export class ApiClient { } async updateUser(token: string, userId: number, userData: any): Promise { - const response = await this.request.put(`${this.baseURL}/api/users/${userId}`, { + const response = await this.request.put(`${this.baseURL}/api/admin/users/${userId}`, { headers: { Authorization: `Bearer ${token}`, }, @@ -81,7 +81,7 @@ export class ApiClient { } async deleteUser(token: string, userId: number): Promise { - const response = await this.request.delete(`${this.baseURL}/api/users/${userId}`, { + const response = await this.request.delete(`${this.baseURL}/api/admin/users/${userId}`, { headers: { Authorization: `Bearer ${token}`, }, @@ -93,7 +93,7 @@ export class ApiClient { } async getRoles(token: string): Promise { - const response = await this.request.get(`${this.baseURL}/api/roles`, { + const response = await this.request.get(`${this.baseURL}/api/admin/roles`, { headers: { Authorization: `Bearer ${token}`, }, @@ -107,7 +107,7 @@ export class ApiClient { } async createRole(token: string, roleData: any): Promise { - const response = await this.request.post(`${this.baseURL}/api/roles`, { + const response = await this.request.post(`${this.baseURL}/api/admin/roles`, { headers: { Authorization: `Bearer ${token}`, }, @@ -122,7 +122,7 @@ export class ApiClient { } async deleteRole(token: string, roleId: number): Promise { - const response = await this.request.delete(`${this.baseURL}/api/roles/${roleId}`, { + const response = await this.request.delete(`${this.baseURL}/api/admin/roles/${roleId}`, { headers: { Authorization: `Bearer ${token}`, }, @@ -134,7 +134,7 @@ export class ApiClient { } async getMenus(token: string): Promise { - const response = await this.request.get(`${this.baseURL}/api/menus`, { + const response = await this.request.get(`${this.baseURL}/api/admin/menus`, { headers: { Authorization: `Bearer ${token}`, }, diff --git a/e2e-tests/utils/testDataManager.ts b/e2e-tests/utils/testDataManager.ts index e99f413..2537632 100644 --- a/e2e-tests/utils/testDataManager.ts +++ b/e2e-tests/utils/testDataManager.ts @@ -55,7 +55,7 @@ export class TestDataManager { } static async createTestUser(request: APIRequestContext, userData: TestUser): Promise { - const response = await request.post(`${this.apiBaseUrl}/api/users`, { + const response = await request.post(`${this.apiBaseUrl}/api/admin/users`, { data: userData, }); @@ -75,7 +75,7 @@ export class TestDataManager { } static async createTestRole(request: APIRequestContext, roleData: TestRole): Promise { - const response = await request.post(`${this.apiBaseUrl}/api/roles`, { + const response = await request.post(`${this.apiBaseUrl}/api/admin/roles`, { data: roleData, }); @@ -100,7 +100,7 @@ export class TestDataManager { return; } - const response = await request.delete(`${this.apiBaseUrl}/api/users/${userData.id}`); + const response = await request.delete(`${this.apiBaseUrl}/api/admin/users/${userData.id}`); if (!response.ok()) { console.warn(`Failed to delete test user ${username}: ${await response.text()}`); } @@ -114,7 +114,7 @@ export class TestDataManager { return; } - const response = await request.delete(`${this.apiBaseUrl}/api/roles/${roleData.id}`); + const response = await request.delete(`${this.apiBaseUrl}/api/admin/roles/${roleData.id}`); if (!response.ok()) { console.warn(`Failed to delete test role ${roleKey}: ${await response.text()}`); } diff --git a/gym-manage-api/manage-gateway/src/main/java/cn/novalon/gym/manage/gateway/filter/JwtAuthenticationFilter.java b/gym-manage-api/manage-gateway/src/main/java/cn/novalon/gym/manage/gateway/filter/JwtAuthenticationFilter.java index 07754f0..49206a7 100644 --- a/gym-manage-api/manage-gateway/src/main/java/cn/novalon/gym/manage/gateway/filter/JwtAuthenticationFilter.java +++ b/gym-manage-api/manage-gateway/src/main/java/cn/novalon/gym/manage/gateway/filter/JwtAuthenticationFilter.java @@ -81,11 +81,9 @@ public class JwtAuthenticationFilter extends AbstractGatewayFilterFactory