diff --git a/backend/internal/handler/admin/admin_basic_handlers_test.go b/backend/internal/handler/admin/admin_basic_handlers_test.go index 6edf35a3..cc5999a8 100644 --- a/backend/internal/handler/admin/admin_basic_handlers_test.go +++ b/backend/internal/handler/admin/admin_basic_handlers_test.go @@ -36,7 +36,6 @@ func setupAdminRouter() (*gin.Engine, *stubAdminService) { router.POST("/api/v1/admin/groups", groupHandler.Create) router.PUT("/api/v1/admin/groups/:id", groupHandler.Update) router.DELETE("/api/v1/admin/groups/:id", groupHandler.Delete) - router.GET("/api/v1/admin/groups/:id/stats", groupHandler.GetStats) router.GET("/api/v1/admin/groups/:id/api-keys", groupHandler.GetGroupAPIKeys) router.GET("/api/v1/admin/proxies", proxyHandler.List) @@ -147,7 +146,7 @@ func TestGroupHandlerEndpoints(t *testing.T) { rec = httptest.NewRecorder() req = httptest.NewRequest(http.MethodGet, "/api/v1/admin/groups/2/stats", nil) router.ServeHTTP(rec, req) - require.Equal(t, http.StatusOK, rec.Code) + require.Equal(t, http.StatusNotFound, rec.Code) rec = httptest.NewRecorder() req = httptest.NewRequest(http.MethodGet, "/api/v1/admin/groups/2/api-keys", nil) @@ -279,6 +278,10 @@ func TestDeprecatedMockAdminEndpointsNotRegistered(t *testing.T) { name string url string }{ + { + name: "group stats", + url: "/api/v1/admin/groups/2/stats", + }, { name: "user usage", url: "/api/v1/admin/users/1/usage?period=today", diff --git a/backend/internal/handler/admin/group_handler.go b/backend/internal/handler/admin/group_handler.go index cb2bd201..2284dbfb 100644 --- a/backend/internal/handler/admin/group_handler.go +++ b/backend/internal/handler/admin/group_handler.go @@ -341,25 +341,6 @@ func (h *GroupHandler) Delete(c *gin.Context) { response.Success(c, gin.H{"message": "Group deleted successfully"}) } -// GetStats handles getting group statistics -// GET /api/v1/admin/groups/:id/stats -func (h *GroupHandler) GetStats(c *gin.Context) { - groupID, err := strconv.ParseInt(c.Param("id"), 10, 64) - if err != nil { - response.BadRequest(c, "Invalid group ID") - return - } - - // Return mock data for now - response.Success(c, gin.H{ - "total_api_keys": 0, - "active_api_keys": 0, - "total_requests": 0, - "total_cost": 0.0, - }) - _ = groupID // TODO: implement actual stats -} - // GetUsageSummary returns today's and cumulative cost for all groups. // GET /api/v1/admin/groups/usage-summary?timezone=Asia/Shanghai func (h *GroupHandler) GetUsageSummary(c *gin.Context) { diff --git a/backend/internal/server/routes/admin.go b/backend/internal/server/routes/admin.go index b80ff5d8..c8c0f4a7 100644 --- a/backend/internal/server/routes/admin.go +++ b/backend/internal/server/routes/admin.go @@ -257,7 +257,6 @@ func registerGroupRoutes(admin *gin.RouterGroup, h *handler.Handlers) { groups.POST("", h.Admin.Group.Create) groups.PUT("/:id", h.Admin.Group.Update) groups.DELETE("/:id", h.Admin.Group.Delete) - groups.GET("/:id/stats", h.Admin.Group.GetStats) groups.GET("/:id/rate-multipliers", h.Admin.Group.GetGroupRateMultipliers) groups.PUT("/:id/rate-multipliers", h.Admin.Group.BatchSetGroupRateMultipliers) groups.DELETE("/:id/rate-multipliers", h.Admin.Group.ClearGroupRateMultipliers) diff --git a/backend/internal/server/routes/admin_routes_test.go b/backend/internal/server/routes/admin_routes_test.go index e141391a..6df3ac8a 100644 --- a/backend/internal/server/routes/admin_routes_test.go +++ b/backend/internal/server/routes/admin_routes_test.go @@ -29,6 +29,7 @@ func TestRegisterAdminRoutes_OmitsDeprecatedMockEndpoints(t *testing.T) { deprecatedRoutes := []string{ "GET /api/v1/admin/dashboard/realtime", + "GET /api/v1/admin/groups/:id/stats", "GET /api/v1/admin/users/:id/usage", "GET /api/v1/admin/proxies/:id/stats", "GET /api/v1/admin/redeem-codes/stats", diff --git a/frontend/src/api/admin/groups.ts b/frontend/src/api/admin/groups.ts index 8739d5cb..a4f5d972 100644 --- a/frontend/src/api/admin/groups.ts +++ b/frontend/src/api/admin/groups.ts @@ -117,26 +117,6 @@ export async function toggleStatus(id: number, status: 'active' | 'inactive'): P return update(id, { status }) } -/** - * Get group statistics - * @param id - Group ID - * @returns Group usage statistics - */ -export async function getStats(id: number): Promise<{ - total_api_keys: number - active_api_keys: number - total_requests: number - total_cost: number -}> { - const { data } = await apiClient.get<{ - total_api_keys: number - active_api_keys: number - total_requests: number - total_cost: number - }>(`/admin/groups/${id}/stats`) - return data -} - /** * Get API keys in a group * @param id - Group ID @@ -257,7 +237,6 @@ export const groupsAPI = { update, delete: deleteGroup, toggleStatus, - getStats, getGroupApiKeys, getGroupRateMultipliers, clearGroupRateMultipliers,