90ac0b81d1
Add full V2 architecture: identity, content, studio (.NET 10) and file, render, notification, gateway (Go) services with vendored deps, plus DB migrations, event/API contracts, and an init-db script. Wire the Next.js frontend to the gateway: server-side JWT auth routes (login/register/refresh/logout/me), gateway fetch helper, and session/ cookie/jwt helpers under src/lib. Containerize the stack via docker-compose.v2.yml and per-service Dockerfiles. Base images resolve through a Nexus mirror (Docker Hub) and MCR directly; npm/NuGet pull from Nexus groups. Self-host fonts via next/font/local to avoid Google Fonts (geo-blocked). Add CI workflow and ignore .env.v2, *.stackdump, and .NET bin/obj. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
58 lines
2.1 KiB
C#
58 lines
2.1 KiB
C#
using System.Security.Claims;
|
|
using FlatRender.StudioSvc.Application.Services;
|
|
using FlatRender.StudioSvc.Models.Requests;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace FlatRender.StudioSvc.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("v1/saved-projects")]
|
|
[Authorize]
|
|
public class StudioController(StudioService svc) : ControllerBase
|
|
{
|
|
private Guid UserId => Guid.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier)!);
|
|
private Guid TenantId => Guid.Parse(
|
|
User.FindFirstValue("tenant_id") ?? "00000000-0000-0000-0000-000000000001");
|
|
|
|
[HttpGet]
|
|
public async Task<IActionResult> List([FromQuery] SavedProjectListRequest req) =>
|
|
Ok(await svc.ListProjectsAsync(UserId, req));
|
|
|
|
[HttpGet("{id:guid}")]
|
|
public async Task<IActionResult> Get(Guid id) =>
|
|
Ok(await svc.GetProjectAsync(id, UserId));
|
|
|
|
[HttpPost]
|
|
public async Task<IActionResult> Create([FromBody] CreateSavedProjectRequest req)
|
|
{
|
|
var result = await svc.CreateProjectAsync(UserId, TenantId, req);
|
|
return CreatedAtAction(nameof(Get), new { id = result.Id }, result);
|
|
}
|
|
|
|
[HttpPatch("{id:guid}")]
|
|
public async Task<IActionResult> Update(Guid id, [FromBody] UpdateSavedProjectRequest req) =>
|
|
Ok(await svc.UpdateProjectAsync(id, UserId, req));
|
|
|
|
[HttpDelete("{id:guid}")]
|
|
public async Task<IActionResult> Delete(Guid id)
|
|
{
|
|
await svc.DeleteProjectAsync(id, UserId);
|
|
return NoContent();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Save all scenes for a project (full atomic replace).
|
|
/// Called by the studio editor on every save.
|
|
/// </summary>
|
|
[HttpPut("{id:guid}/scenes")]
|
|
public async Task<IActionResult> SaveScenes(Guid id, [FromBody] List<SaveSceneRequest> scenes) =>
|
|
Ok(await svc.SaveScenesAsync(id, UserId, scenes));
|
|
|
|
/// <summary>Internal endpoint: get project for render service (no user-ownership check).</summary>
|
|
[HttpGet("{id:guid}/render-payload")]
|
|
[Authorize(Roles = "Service")]
|
|
public async Task<IActionResult> GetRenderPayload(Guid id) =>
|
|
Ok(await svc.GetProjectForRenderAsync(id));
|
|
}
|