feat random bullshit GO!

This commit is contained in:
elar1s
2025-09-29 21:46:35 +03:00
parent 63c89c48d5
commit 8d68a719d4
2 changed files with 69 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
using LctMonolith.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace LctMonolith.Controllers;
/// <summary>
/// Basic analytics endpoints.
/// </summary>
[ApiController]
[Route("api/analytics")]
[Authorize]
public class AnalyticsController : ControllerBase
{
private readonly IAnalyticsService _analytics;
public AnalyticsController(IAnalyticsService analytics)
{
_analytics = analytics;
}
/// <summary>Get aggregate system summary metrics.</summary>
[HttpGet("summary")]
public async Task<IActionResult> GetSummary(CancellationToken ct)
{
var summary = await _analytics.GetSummaryAsync(ct);
return Ok(summary);
}
}

View File

@@ -0,0 +1,40 @@
using System.Security.Claims;
using LctMonolith.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace LctMonolith.Controllers;
/// <summary>
/// Inventory endpoints for viewing owned store items and artifacts.
/// </summary>
[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)!);
/// <summary>List owned store inventory entries.</summary>
[HttpGet("store-items")]
public async Task<IActionResult> 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 }));
}
/// <summary>List owned artifacts.</summary>
[HttpGet("artifacts")]
public async Task<IActionResult> 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 }));
}
}