diff --git a/DysonNetwork.Sphere/Sticker/StickerController.cs b/DysonNetwork.Sphere/Sticker/StickerController.cs index bb36299..e4aa2a7 100644 --- a/DysonNetwork.Sphere/Sticker/StickerController.cs +++ b/DysonNetwork.Sphere/Sticker/StickerController.cs @@ -237,6 +237,22 @@ public class StickerController( return Redirect($"/drive/files/{sticker.Image.Id}?original=true"); } + [HttpGet("search")] + public async Task>> SearchSticker([FromQuery] string query, [FromQuery] int take = 10, [FromQuery] int offset = 0) + { + var queryable = db.Stickers + .Include(s => s.Pack) + .Where(s => EF.Functions.Like(s.Pack.Prefix + "+" + s.Slug, $"{query}%")) + .OrderByDescending(s => s.CreatedAt) + .AsQueryable(); + + var totalCount = await queryable.CountAsync(); + Response.Headers["X-Total"] = totalCount.ToString(); + + var stickers = await queryable.Take(take).Skip(offset).ToListAsync(); + return Ok(stickers); + } + [HttpGet("{packId:guid}/content/{id:guid}")] public async Task> GetSticker(Guid packId, Guid id) { @@ -420,4 +436,4 @@ public class StickerController( return NoContent(); } -} \ No newline at end of file +}