🐛 Fix missing pagination query in discovery controller

This commit is contained in:
LittleSheep 2025-06-27 18:02:12 +08:00
parent 0bdd429d87
commit 9f8eec792b
2 changed files with 9 additions and 13 deletions

View File

@ -1,6 +1,3 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using DysonNetwork.Sphere.Realm;
using Microsoft.AspNetCore.Mvc;
namespace DysonNetwork.Sphere.Discovery;
@ -10,8 +7,13 @@ namespace DysonNetwork.Sphere.Discovery;
public class DiscoveryController(DiscoveryService discoveryService) : ControllerBase
{
[HttpGet("realms")]
public Task<List<Realm.Realm>> GetPublicRealms([FromQuery] string? query, [FromQuery] List<string>? tags)
public Task<List<Realm.Realm>> GetPublicRealms(
[FromQuery] string? query,
[FromQuery] List<string>? tags,
[FromQuery] int take = 10,
[FromQuery] int offset = 0
)
{
return discoveryService.GetPublicRealmsAsync(query, tags);
return discoveryService.GetPublicRealmsAsync(query, tags, take, offset);
}
}
}

View File

@ -1,10 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using DysonNetwork.Sphere;
using DysonNetwork.Sphere.Realm;
using Microsoft.EntityFrameworkCore;
namespace DysonNetwork.Sphere.Discovery;
public class DiscoveryService(AppDatabase appDatabase)
@ -35,4 +29,4 @@ public class DiscoveryService(AppDatabase appDatabase)
return realmsQuery.Skip(offset).Take(take).ToListAsync();
}
}
}