Files
flatrender/services/content/FlatRender.ContentSvc/Controllers/TemplatesController.cs
T
soroush.asadi cf5dd4f195
Build backend images / build content-svc (push) Failing after 21s
Build backend images / build file-svc (push) Failing after 3m49s
Build backend images / build gateway (push) Failing after 1m2s
Build backend images / build identity-svc (push) Failing after 1m1s
Build backend images / build notification-svc (push) Failing after 1m2s
Build backend images / build render-svc (push) Failing after 1m0s
Build backend images / build studio-svc (push) Failing after 58s
feat(admin): category SEO fields, Templates admin, safe project PATCH
- categories/tags admin forms: add meta title/description/keywords, bot-follow,
  sort, is_active (backend already supported these)
- new Templates admin (/admin/templates): container CRUD with description,
  keywords, publishing, premium, primary mode, category/tag assignment, plus
  editable per-variant aspect & resolution
- content-svc: PATCH /v1/projects/{id} partial update so aspect/resolution edits
  never wipe render/colour data (SharedColorsSvg, RenderAepComp, Folder)
- admin resource proxy: add PATCH passthrough

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 14:26:44 +03:30

77 lines
2.7 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/templates")]
public class TemplatesController(TemplateService svc) : ControllerBase
{
// ── Containers ────────────────────────────────────────────────────────────
[HttpGet]
public async Task<IActionResult> ListContainers([FromQuery] ContainerListRequest req) =>
Ok(await svc.GetContainersAsync(req));
[HttpGet("{slug}")]
public async Task<IActionResult> GetContainer(string slug)
{
await svc.IncrementContainerViewAsync(
(await svc.GetContainerBySlugAsync(slug)).Id);
return Ok(await svc.GetContainerBySlugAsync(slug));
}
[Authorize(Roles = "Admin")]
[HttpPost]
public async Task<IActionResult> CreateContainer([FromBody] CreateContainerRequest req) =>
Ok(await svc.CreateContainerAsync(req));
[Authorize(Roles = "Admin")]
[HttpPut("{id:guid}")]
public async Task<IActionResult> UpdateContainer(Guid id, [FromBody] UpdateContainerRequest req) =>
Ok(await svc.UpdateContainerAsync(id, req));
[Authorize(Roles = "Admin")]
[HttpDelete("{id:guid}")]
public async Task<IActionResult> DeleteContainer(Guid id)
{
await svc.DeleteContainerAsync(id);
return NoContent();
}
}
[ApiController]
[Route("v1/projects")]
public class ProjectsController(TemplateService svc) : ControllerBase
{
[HttpGet("{id:guid}")]
public async Task<IActionResult> GetProject(Guid id) =>
Ok(await svc.GetProjectDetailAsync(id));
[Authorize(Roles = "Admin")]
[HttpPost]
public async Task<IActionResult> CreateProject([FromBody] CreateProjectRequest req) =>
Ok(await svc.CreateProjectAsync(req));
[Authorize(Roles = "Admin")]
[HttpPut("{id:guid}")]
public async Task<IActionResult> UpdateProject(Guid id, [FromBody] UpdateProjectRequest req) =>
Ok(await svc.UpdateProjectAsync(id, req));
// Partial update (aspect / resolution / dimensions / duration) without wiping other fields.
[Authorize(Roles = "Admin")]
[HttpPatch("{id:guid}")]
public async Task<IActionResult> PatchProject(Guid id, [FromBody] PatchProjectRequest req) =>
Ok(await svc.PatchProjectAsync(id, req));
[Authorize(Roles = "Admin")]
[HttpDelete("{id:guid}")]
public async Task<IActionResult> DeleteProject(Guid id)
{
await svc.DeleteProjectAsync(id);
return NoContent();
}
}