✨ Able to list sticker packs with pubName
This commit is contained in:
parent
130ad8f186
commit
c4f6798fd0
@ -12,7 +12,8 @@ namespace DysonNetwork.Sphere.Sticker;
|
||||
[Route("/stickers")]
|
||||
public class StickerController(AppDatabase db, StickerService st) : ControllerBase
|
||||
{
|
||||
private async Task<IActionResult> _CheckStickerPackPermissions(Guid packId, Account.Account currentUser, PublisherMemberRole requiredRole)
|
||||
private async Task<IActionResult> _CheckStickerPackPermissions(Guid packId, Account.Account currentUser,
|
||||
PublisherMemberRole requiredRole)
|
||||
{
|
||||
var pack = await db.StickerPacks
|
||||
.Include(p => p.Publisher)
|
||||
@ -32,11 +33,21 @@ public class StickerController(AppDatabase db, StickerService st) : ControllerBa
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<List<StickerPack>>> ListStickerPacks([FromQuery] int offset = 0,
|
||||
[FromQuery] int take = 20)
|
||||
public async Task<ActionResult<List<StickerPack>>> ListStickerPacks(
|
||||
[FromQuery] int offset = 0,
|
||||
[FromQuery] int take = 20,
|
||||
[FromQuery] string? pubName = null
|
||||
)
|
||||
{
|
||||
var totalCount = await db.StickerPacks.CountAsync();
|
||||
Publisher.Publisher? publisher = null;
|
||||
if (pubName is not null)
|
||||
publisher = await db.Publishers.FirstOrDefaultAsync(p => p.Name == pubName);
|
||||
|
||||
var totalCount = await db.StickerPacks
|
||||
.If(publisher is not null, q => q.Where(f => f.PublisherId == publisher!.Id))
|
||||
.CountAsync();
|
||||
var packs = await db.StickerPacks
|
||||
.If(publisher is not null, q => q.Where(f => f.PublisherId == publisher!.Id))
|
||||
.OrderByDescending(e => e.CreatedAt)
|
||||
.Skip(offset)
|
||||
.Take(take)
|
||||
|
Loading…
x
Reference in New Issue
Block a user