From 8d68a719d4bd6217c0f365a8d86413455bc3345e Mon Sep 17 00:00:00 2001 From: elar1s Date: Mon, 29 Sep 2025 21:46:35 +0300 Subject: [PATCH] feat random bullshit GO! --- .../Controllers/AnalyticsController.cs | 29 ++++++++++++++ .../Controllers/InventoryController.cs | 40 +++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 LctMonolith/Controllers/AnalyticsController.cs create mode 100644 LctMonolith/Controllers/InventoryController.cs diff --git a/LctMonolith/Controllers/AnalyticsController.cs b/LctMonolith/Controllers/AnalyticsController.cs new file mode 100644 index 0000000..5e89f40 --- /dev/null +++ b/LctMonolith/Controllers/AnalyticsController.cs @@ -0,0 +1,29 @@ +using LctMonolith.Services; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace LctMonolith.Controllers; + +/// +/// Basic analytics endpoints. +/// +[ApiController] +[Route("api/analytics")] +[Authorize] +public class AnalyticsController : ControllerBase +{ + private readonly IAnalyticsService _analytics; + public AnalyticsController(IAnalyticsService analytics) + { + _analytics = analytics; + } + + /// Get aggregate system summary metrics. + [HttpGet("summary")] + public async Task GetSummary(CancellationToken ct) + { + var summary = await _analytics.GetSummaryAsync(ct); + return Ok(summary); + } +} + diff --git a/LctMonolith/Controllers/InventoryController.cs b/LctMonolith/Controllers/InventoryController.cs new file mode 100644 index 0000000..eb025bc --- /dev/null +++ b/LctMonolith/Controllers/InventoryController.cs @@ -0,0 +1,40 @@ +using System.Security.Claims; +using LctMonolith.Services; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace LctMonolith.Controllers; + +/// +/// Inventory endpoints for viewing owned store items and artifacts. +/// +[ApiController] +[Route("api/inventory")] +[Authorize] +public class InventoryController : ControllerBase +{ + private readonly IInventoryService _inventory; + public InventoryController(IInventoryService inventory) + { + _inventory = inventory; + } + + private Guid GetUserId() => Guid.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier)!); + + /// List owned store inventory entries. + [HttpGet("store-items")] + public async Task GetStoreItems(CancellationToken ct) + { + var items = await _inventory.GetStoreInventoryAsync(GetUserId(), ct); + return Ok(items.Select(i => new { i.StoreItemId, i.Quantity, i.AcquiredAt, i.IsReturned, i.StoreItem?.Name })); + } + + /// List owned artifacts. + [HttpGet("artifacts")] + public async Task GetArtifacts(CancellationToken ct) + { + var artifacts = await _inventory.GetArtifactsAsync(GetUserId(), ct); + return Ok(artifacts.Select(a => new { a.ArtifactId, a.ObtainedAt, a.Artifact?.Name, a.Artifact?.Rarity })); + } +} +