using FlatRender.ContentSvc.Application.Services; using FlatRender.ContentSvc.Models; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace FlatRender.ContentSvc.Controllers; /// Import a scanned AE project structure into a project's scenes/elements/colours. [ApiController] [Route("v1/projects")] public class AepImportController(AepImportService svc) : ControllerBase { /// Dry run — returns the diff (added/changed/removed) without writing. [Authorize(Roles = "Admin")] [HttpPost("{id:guid}/scan/preview")] public async Task Preview(Guid id, [FromBody] ScanImportRequest req) { if (req?.Scan is null) return BadRequest(new { message = "scan is required" }); return Ok(await svc.PreviewAsync(id, req.Scan)); } /// Apply the scan, merging into the project (matched items refreshed, new added). [Authorize(Roles = "Admin")] [HttpPost("{id:guid}/scan/apply")] public async Task Apply(Guid id, [FromBody] ScanImportRequest req) { if (req?.Scan is null) return BadRequest(new { message = "scan is required" }); return Ok(await svc.ApplyAsync(id, req.Scan, req.Options ?? new ScanApplyOptions())); } }