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>
109 lines
4.2 KiB
C#
109 lines
4.2 KiB
C#
using FlatRender.ContentSvc.Application.Services;
|
|
using FlatRender.ContentSvc.Models.Requests;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace FlatRender.ContentSvc.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("v1")]
|
|
public class TaxonomyController(TaxonomyService svc) : ControllerBase
|
|
{
|
|
// ── Categories ────────────────────────────────────────────────────────────
|
|
|
|
[HttpGet("categories")]
|
|
public async Task<IActionResult> GetCategories() =>
|
|
Ok(await svc.GetCategoryTreeAsync());
|
|
|
|
[Authorize(Roles = "Admin")]
|
|
[HttpPost("categories")]
|
|
public async Task<IActionResult> CreateCategory([FromBody] CreateCategoryRequest req) =>
|
|
Ok(await svc.CreateCategoryAsync(req));
|
|
|
|
[Authorize(Roles = "Admin")]
|
|
[HttpPut("categories/{id:guid}")]
|
|
public async Task<IActionResult> UpdateCategory(Guid id, [FromBody] UpdateCategoryRequest req) =>
|
|
Ok(await svc.UpdateCategoryAsync(id, req));
|
|
|
|
[Authorize(Roles = "Admin")]
|
|
[HttpDelete("categories/{id:guid}")]
|
|
public async Task<IActionResult> DeleteCategory(Guid id)
|
|
{
|
|
await svc.DeleteCategoryAsync(id);
|
|
return NoContent();
|
|
}
|
|
|
|
// ── Tags ──────────────────────────────────────────────────────────────────
|
|
|
|
[HttpGet("tags")]
|
|
public async Task<IActionResult> GetTags(
|
|
[FromQuery] int page = 1, [FromQuery] int pageSize = 50,
|
|
[FromQuery] string? search = null) =>
|
|
Ok(await svc.GetTagsAsync(page, pageSize, search));
|
|
|
|
[Authorize(Roles = "Admin")]
|
|
[HttpPost("tags")]
|
|
public async Task<IActionResult> CreateTag([FromBody] CreateTagRequest req) =>
|
|
Ok(await svc.CreateTagAsync(req));
|
|
|
|
[Authorize(Roles = "Admin")]
|
|
[HttpPut("tags/{id:guid}")]
|
|
public async Task<IActionResult> UpdateTag(Guid id, [FromBody] UpdateTagRequest req) =>
|
|
Ok(await svc.UpdateTagAsync(id, req));
|
|
|
|
[Authorize(Roles = "Admin")]
|
|
[HttpDelete("tags/{id:guid}")]
|
|
public async Task<IActionResult> DeleteTag(Guid id)
|
|
{
|
|
await svc.DeleteTagAsync(id);
|
|
return NoContent();
|
|
}
|
|
|
|
// ── Fonts ─────────────────────────────────────────────────────────────────
|
|
|
|
[HttpGet("fonts")]
|
|
public async Task<IActionResult> GetFonts(
|
|
[FromQuery] int page = 1, [FromQuery] int pageSize = 50,
|
|
[FromQuery] string? search = null, [FromQuery] string? direction = null) =>
|
|
Ok(await svc.GetFontsAsync(page, pageSize, search, direction));
|
|
|
|
[Authorize(Roles = "Admin")]
|
|
[HttpPost("fonts")]
|
|
public async Task<IActionResult> CreateFont([FromBody] CreateFontRequest req) =>
|
|
Ok(await svc.CreateFontAsync(req));
|
|
|
|
[Authorize(Roles = "Admin")]
|
|
[HttpPut("fonts/{id:guid}")]
|
|
public async Task<IActionResult> UpdateFont(Guid id, [FromBody] UpdateFontRequest req) =>
|
|
Ok(await svc.UpdateFontAsync(id, req));
|
|
|
|
[Authorize(Roles = "Admin")]
|
|
[HttpDelete("fonts/{id:guid}")]
|
|
public async Task<IActionResult> DeleteFont(Guid id)
|
|
{
|
|
await svc.DeleteFontAsync(id);
|
|
return NoContent();
|
|
}
|
|
|
|
// ── Music Tracks ──────────────────────────────────────────────────────────
|
|
|
|
[HttpGet("music")]
|
|
public async Task<IActionResult> GetMusicTracks(
|
|
[FromQuery] int page = 1, [FromQuery] int pageSize = 50,
|
|
[FromQuery] string? search = null) =>
|
|
Ok(await svc.GetMusicTracksAsync(page, pageSize, search));
|
|
|
|
[Authorize(Roles = "Admin")]
|
|
[HttpPost("music")]
|
|
public async Task<IActionResult> CreateMusicTrack([FromBody] CreateMusicTrackRequest req) =>
|
|
Ok(await svc.CreateMusicTrackAsync(req));
|
|
|
|
[Authorize(Roles = "Admin")]
|
|
[HttpDelete("music/{id:guid}")]
|
|
public async Task<IActionResult> DeleteMusicTrack(Guid id)
|
|
{
|
|
await svc.DeleteMusicTrackAsync(id);
|
|
return NoContent();
|
|
}
|
|
}
|