From 5b506cc79b8ed8ead1597cc94f3fcadf1f4a4dce Mon Sep 17 00:00:00 2001 From: Felix Cornelissen Date: Tue, 24 Sep 2024 15:11:31 +0200 Subject: [PATCH] chore: backend mocks voor documenten en formats --- .../DocumentDetailController.cs | 16 +++++++++ .../Features/Documenten/DocumentenMock.cs | 24 +++++++++++++ .../DocumentenOverzichtController.cs | 18 ++++++++++ .../InitialiseerDocumentController.cs | 36 +++++++++++++++++++ .../Features/Documenten/PublicatieDocument.cs | 23 ++++++++++++ .../UploadBestandsdeelController.cs | 14 ++++++++ ODPC.Server/Features/Formats/Format.cs | 9 +++++ ODPC.Server/Features/Formats/FormatsMock.cs | 28 +++++++++++++++ .../FormatsOverzichtController.cs | 14 ++++++++ 9 files changed, 182 insertions(+) create mode 100644 ODPC.Server/Features/Documenten/DocumentDetail/DocumentDetailController.cs create mode 100644 ODPC.Server/Features/Documenten/DocumentenMock.cs create mode 100644 ODPC.Server/Features/Documenten/DocumentenOverzicht/DocumentenOverzichtController.cs create mode 100644 ODPC.Server/Features/Documenten/InitialiseerDocument/InitialiseerDocumentController.cs create mode 100644 ODPC.Server/Features/Documenten/PublicatieDocument.cs create mode 100644 ODPC.Server/Features/Documenten/UploadBestandsdeel/UploadBestandsdeelController.cs create mode 100644 ODPC.Server/Features/Formats/Format.cs create mode 100644 ODPC.Server/Features/Formats/FormatsMock.cs create mode 100644 ODPC.Server/Features/Formats/FormatsOverzicht/FormatsOverzichtController.cs diff --git a/ODPC.Server/Features/Documenten/DocumentDetail/DocumentDetailController.cs b/ODPC.Server/Features/Documenten/DocumentDetail/DocumentDetailController.cs new file mode 100644 index 0000000..304b47c --- /dev/null +++ b/ODPC.Server/Features/Documenten/DocumentDetail/DocumentDetailController.cs @@ -0,0 +1,16 @@ +using Microsoft.AspNetCore.Mvc; + +namespace ODPC.Features.Documenten.DocumentDetail +{ + [ApiController] + public class DocumentDetailController: ControllerBase + { + [HttpGet("api/v1/documenten/{uuid:guid}")] + public IActionResult Get(Guid uuid) + { + return DocumentenMock.Documenten.TryGetValue(uuid, out var document) + ? Ok(document) + : NotFound(); + } + } +} diff --git a/ODPC.Server/Features/Documenten/DocumentenMock.cs b/ODPC.Server/Features/Documenten/DocumentenMock.cs new file mode 100644 index 0000000..4db7c09 --- /dev/null +++ b/ODPC.Server/Features/Documenten/DocumentenMock.cs @@ -0,0 +1,24 @@ +using ODPC.Features.Publicaties; + +namespace ODPC.Features.Documenten +{ + public static class DocumentenMock + { + public static readonly Dictionary Documenten = new PublicatieDocument[] + { + new() + { + Uuid = Guid.NewGuid(), + Publicatie = PublicatiesMock.Publicaties.Keys.First(), + OfficieleTitel = "Belangrijk document", + VerkorteTitel = "Document", + Omschrijving = "", + Creatiedatum = new DateOnly(2024, 09, 23), + Bestandsformaat = "DOCX", + Bestandsnaam = "belangrijk.docx", + Bestandsomvang = 100000 + } + } + .ToDictionary(x => x.Uuid); + } +} diff --git a/ODPC.Server/Features/Documenten/DocumentenOverzicht/DocumentenOverzichtController.cs b/ODPC.Server/Features/Documenten/DocumentenOverzicht/DocumentenOverzichtController.cs new file mode 100644 index 0000000..41932c7 --- /dev/null +++ b/ODPC.Server/Features/Documenten/DocumentenOverzicht/DocumentenOverzichtController.cs @@ -0,0 +1,18 @@ +using Microsoft.AspNetCore.Mvc; + +namespace ODPC.Features.Documenten.DocumentenOverzicht +{ + [ApiController] + public class DocumentenOverzichtController : ControllerBase + { + [HttpGet("api/v1/documenten")] + public IActionResult Get([FromQuery] Guid publicatie) + { + var documenten = DocumentenMock.Documenten.Values + .Where(x=> x.Publicatie == publicatie) + .ToList(); + + return Ok(documenten); + } + } +} diff --git a/ODPC.Server/Features/Documenten/InitialiseerDocument/InitialiseerDocumentController.cs b/ODPC.Server/Features/Documenten/InitialiseerDocument/InitialiseerDocumentController.cs new file mode 100644 index 0000000..451f767 --- /dev/null +++ b/ODPC.Server/Features/Documenten/InitialiseerDocument/InitialiseerDocumentController.cs @@ -0,0 +1,36 @@ +using Microsoft.AspNetCore.Mvc; + +namespace ODPC.Features.Documenten.InitialiseerDocument +{ + [ApiController] + public class InitialiseerDocumentController : ControllerBase + { + [HttpPost("api/v1/documenten")] + public IActionResult Post(PublicatieDocument document) + { + document.Uuid = Guid.NewGuid(); + var halve = document.Bestandsomvang / 2; + var firstSize = Math.Ceiling(halve); + var secondSize = Math.Floor(halve); + + document.Bestandsdelen = + [ + new() + { + Omvang = firstSize, + Url = $"/api/v1/{document.Uuid}/1", + Volgnummer = 0 + }, + new() + { + Omvang = secondSize, + Url = $"/api/v1/{document.Uuid}/2", + Volgnummer = 1 + } + ]; + + DocumentenMock.Documenten[document.Uuid] = document; + return Ok(document); + } + } +} diff --git a/ODPC.Server/Features/Documenten/PublicatieDocument.cs b/ODPC.Server/Features/Documenten/PublicatieDocument.cs new file mode 100644 index 0000000..83fe769 --- /dev/null +++ b/ODPC.Server/Features/Documenten/PublicatieDocument.cs @@ -0,0 +1,23 @@ +namespace ODPC.Features.Documenten +{ + public class PublicatieDocument + { + public Guid Uuid { get; set; } + public Guid Publicatie { get; set; } + public required string OfficieleTitel { get; set; } + public string? VerkorteTitel { get; set; } + public string? Omschrijving { get; set; } + public DateOnly Creatiedatum { get; set; } + public required string Bestandsnaam { get; set; } + public required string Bestandsformaat { get; set; } + public required double Bestandsomvang { get; set; } + public List? Bestandsdelen { get; set; } + } + + public class Bestandsdeel + { + public required string Url { get; set; } + public required int Volgnummer { get; set; } + public required double Omvang { get; set; } + } +} diff --git a/ODPC.Server/Features/Documenten/UploadBestandsdeel/UploadBestandsdeelController.cs b/ODPC.Server/Features/Documenten/UploadBestandsdeel/UploadBestandsdeelController.cs new file mode 100644 index 0000000..c74e5df --- /dev/null +++ b/ODPC.Server/Features/Documenten/UploadBestandsdeel/UploadBestandsdeelController.cs @@ -0,0 +1,14 @@ +using Microsoft.AspNetCore.Mvc; + +namespace ODPC.Features.Documenten.UploadBestandsdeel +{ + [ApiController] + public class UploadBestandsdeelController : ControllerBase + { + [HttpPut("api/v1/documenten/{uuid:guid}/bestandsdelen/{volgnummer:int}")] + public IActionResult Put(Guid uuid, int volgnummer) + { + return NoContent(); + } + } +} diff --git a/ODPC.Server/Features/Formats/Format.cs b/ODPC.Server/Features/Formats/Format.cs new file mode 100644 index 0000000..a660963 --- /dev/null +++ b/ODPC.Server/Features/Formats/Format.cs @@ -0,0 +1,9 @@ +namespace ODPC.Features.Formats +{ + public class Format + { + public required string Identifier { get; set; } + public required string Name { get; set; } + public required string MimeType { get; set; } + } +} diff --git a/ODPC.Server/Features/Formats/FormatsMock.cs b/ODPC.Server/Features/Formats/FormatsMock.cs new file mode 100644 index 0000000..f18fa22 --- /dev/null +++ b/ODPC.Server/Features/Formats/FormatsMock.cs @@ -0,0 +1,28 @@ +namespace ODPC.Features.Formats +{ + public static class FormatsMock + { + public static readonly Dictionary Formats = new Format[] + { + new() { Name = "7z", MimeType = "application/x-7z-compressed", Identifier = "a81129a3-ec70-40f3-8eb6-fc94e97ef865" }, + new() { Name = "CSV", MimeType = "text/csv", Identifier = "6bdd2631-b5d5-472a-b336-9cc643822f0a" }, + new() { Name = "Excel XLS", MimeType = "application/vnd.ms-excel", Identifier = "822928f7-73f0-45d3-b1a0-4f3a3dbc361a" }, + new() { Name = "Excel XLSX", MimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", Identifier = "fd16ded8-f013-4ca7-ba21-ee3ca36a6054" }, + new() { Name = "HTML", MimeType = "text/html", Identifier = "bf16a8af-f40b-4e36-96e3-0bdd5d6f5316" }, + new() { Name = "ODF", MimeType = "application/vnd.oasis.opendocument.formula", Identifier = "26a3df9c-290c-40a4-98cb-387842816698" }, + new() { Name = "ODP", MimeType = "application/vnd.oasis.opendocument.presentation", Identifier = "8b31aa20-d284-4540-aca4-222e1394c1d5" }, + new() { Name = "ODS", MimeType = "application/vnd.oasis.opendocument.spreadsheet", Identifier = "837abc18-616f-4e82-945b-fe78ab939860" }, + new() { Name = "ODT", MimeType = "application/vnd.oasis.opendocument.text", Identifier = "53b7d662-4413-4901-a3a4-6c129fcb93c1" }, + new() { Name = "PDF", MimeType = "application/pdf", Identifier = "a8836b30-8b25-4af6-9b35-e68e4f644c59" }, + new() { Name = "TXT", MimeType = "text/plain", Identifier = "549c6a31-6274-4b51-8528-fa9de141681e" }, + new() { Name = "PPSX", MimeType = "application/vnd.openxmlformats-officedocument.presentationml.slideshow", Identifier = "ff7cf4ad-372f-4996-b6af-5bf8c5b178d8" }, + new() { Name = "PPT", MimeType = "application/vnd.ms-powerpoint", Identifier = "580e3592-c5b2-40d0-ab7a-0c626c8e171a" }, + new() { Name = "PPTX", MimeType = "application/vnd.openxmlformats-officedocument.presentationml.presentation", Identifier = "fc188a40-f0bf-415f-a339-fd7520b531f8" }, + new() { Name = "PPS", MimeType = "application/vnd.ms-powerpoint.slideshow.macroEnabled.12", Identifier = "65298a3a-346d-4614-9fee-028f532ed8bc" }, + new() { Name = "RTF", MimeType = "application/rtf", Identifier = "63026476-5d40-424e-a113-b02ed7fba760" }, + new() { Name = "DOC", MimeType = "application/msword", Identifier = "26ccc5e3-acf2-4251-9618-46321e2b9d36" }, + new() { Name = "DOCX", MimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document", Identifier = "ae0ea877-3207-4a97-b5df-bf552bc9b895" }, + new() { Name = "ZIP", MimeType = "application/zip", Identifier = "f879f55e-a9c2-4779-96b2-288d6359d86b" } + }.ToDictionary(x => x.Identifier); + } +} diff --git a/ODPC.Server/Features/Formats/FormatsOverzicht/FormatsOverzichtController.cs b/ODPC.Server/Features/Formats/FormatsOverzicht/FormatsOverzichtController.cs new file mode 100644 index 0000000..bcbeb0e --- /dev/null +++ b/ODPC.Server/Features/Formats/FormatsOverzicht/FormatsOverzichtController.cs @@ -0,0 +1,14 @@ +using Microsoft.AspNetCore.Mvc; + +namespace ODPC.Features.Formats.FormatsOverzicht +{ + [ApiController] + public class FormatsOverzichtController : ControllerBase + { + [HttpGet("/api/v1/formats")] + public IActionResult Get() + { + return Ok(FormatsMock.Formats.Values.OrderBy(x => x.Name)); + } + } +}