37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using PlotLine.Services;
|
|
|
|
namespace PlotLine.Controllers;
|
|
|
|
[Authorize]
|
|
[Route("api/story-intelligence")]
|
|
public sealed class StoryIntelligenceVisualisationController(
|
|
ICurrentUserService currentUser,
|
|
IStoryIntelligenceVisualisationSnapshotService snapshots) : ControllerBase
|
|
{
|
|
[HttpGet("runs/{runId:int}/visualisation-snapshot")]
|
|
public async Task<IActionResult> GetSnapshot(int runId)
|
|
{
|
|
if (currentUser.UserId is not int userId)
|
|
{
|
|
return Unauthorized();
|
|
}
|
|
|
|
var snapshot = await snapshots.BuildSnapshotAsync(runId, userId);
|
|
return snapshot is null ? NotFound() : Ok(snapshot);
|
|
}
|
|
|
|
[HttpGet("import-sessions/{importSessionId:int}/visualisation-snapshot")]
|
|
public async Task<IActionResult> GetImportSessionSnapshot(int importSessionId)
|
|
{
|
|
if (currentUser.UserId is not int userId)
|
|
{
|
|
return Unauthorized();
|
|
}
|
|
|
|
var snapshot = await snapshots.BuildImportSessionSnapshotAsync(importSessionId, userId);
|
|
return snapshot is null ? NotFound() : Ok(snapshot);
|
|
}
|
|
}
|