diff --git a/internal/router/game_provider_routes.go b/internal/router/game_provider_routes.go index f048ee3..b096bf8 100644 --- a/internal/router/game_provider_routes.go +++ b/internal/router/game_provider_routes.go @@ -72,9 +72,17 @@ func registerGameProviderRoutes(engine *gin.Engine, javaClient authGateway, regi providerGroup := engine.Group("/app/game/providers") providerGroup.Use(authMiddleware(javaClient)) providerGroup.GET("", func(c *gin.Context) { + if gameprovider.IsEmptyGameListUser(mustAuthUser(c).UserID) { + writeOK(c, gameprovider.ProviderListResponse{Items: []gameprovider.ProviderSummary{}}) + return + } writeOK(c, registry.List()) }) providerGroup.GET("/:provider/room/shortcut", func(c *gin.Context) { + if gameprovider.IsEmptyGameListUser(mustAuthUser(c).UserID) { + writeOK(c, gin.H{"items": []publicRoomGameItem{}}) + return + } provider, ok := resolveGameProvider(c, registry) if !ok { return @@ -87,6 +95,10 @@ func registerGameProviderRoutes(engine *gin.Engine, javaClient authGateway, regi writeOK(c, gin.H{"items": publicRoomGameItems(resp)}) }) providerGroup.GET("/:provider/room/list", func(c *gin.Context) { + if gameprovider.IsEmptyGameListUser(mustAuthUser(c).UserID) { + writeOK(c, publicRoomGameListResponse(&gameprovider.RoomGameListResponse{Items: []gameprovider.RoomGameListItem{}})) + return + } provider, ok := resolveGameProvider(c, registry) if !ok { return diff --git a/internal/service/gameprovider/registry.go b/internal/service/gameprovider/registry.go index bc199d3..e4ca859 100644 --- a/internal/service/gameprovider/registry.go +++ b/internal/service/gameprovider/registry.go @@ -79,7 +79,7 @@ func (r *Registry) List() ProviderListResponse { // ListShortcutGames 返回聚合后的快捷游戏列表。 func (r *Registry) ListShortcutGames(ctx context.Context, user AuthUser, roomID string) ([]RoomGameListItem, error) { - if isEmptyGameListUser(user.UserID) { + if IsEmptyGameListUser(user.UserID) { return []RoomGameListItem{}, nil } if r == nil || len(r.ordered) == 0 { @@ -103,7 +103,7 @@ func (r *Registry) ListShortcutGames(ctx context.Context, user AuthUser, roomID // ListRoomGames 返回聚合后的房间游戏列表。 func (r *Registry) ListRoomGames(ctx context.Context, user AuthUser, roomID, category string) (*RoomGameListResponse, error) { - if isEmptyGameListUser(user.UserID) { + if IsEmptyGameListUser(user.UserID) { return &RoomGameListResponse{Items: []RoomGameListItem{}}, nil } if r == nil || len(r.ordered) == 0 { @@ -124,7 +124,7 @@ func (r *Registry) ListRoomGames(ctx context.Context, user AuthUser, roomID, cat return &RoomGameListResponse{Items: items}, nil } -func isEmptyGameListUser(userID int64) bool { +func IsEmptyGameListUser(userID int64) bool { _, ok := emptyGameListUserIDs[userID] return ok }