feat random bullshit GO!
This commit is contained in:
29
LctMonolith/Controllers/AnalyticsController.cs
Normal file
29
LctMonolith/Controllers/AnalyticsController.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
|
||||
40
LctMonolith/Controllers/InventoryController.cs
Normal file
40
LctMonolith/Controllers/InventoryController.cs
Normal 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 }));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user