Skip to content

Commit

Permalink
Merge pull request #45 from GeneriekPublicatiePlatformWoo/34-mock-op-…
Browse files Browse the repository at this point in the history
…backend

chore: mock maken voor publicaties op backend
  • Loading branch information
felixcicatt authored Sep 23, 2024
2 parents 0bc421f + 50debd9 commit bf9ce58
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 2 deletions.
12 changes: 12 additions & 0 deletions ODPC.Server/Features/Publicaties/Publicatie.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace ODPC.Features.Publicaties
{
public class Publicatie
{
public Guid Uuid { get; set; }
public string? OfficieleTitel { get; set; }
public string? VerkorteTitel { get; set; }
public string? Omschrijving { get; set; }
public DateOnly Creatiedatum { get; set; }
public string? Status { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Microsoft.AspNetCore.Mvc;

namespace ODPC.Features.Publicaties.PublicatieBijwerken
{
[ApiController]
public class PublicatieBijwerkenController : ControllerBase
{
[HttpPut("api/v1/publicaties/{uuid}")]
public IActionResult Put(Guid uuid, Publicatie publicatie)
{
PublicatiesMock.Publicaties[uuid] = publicatie;
return Ok(publicatie);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Microsoft.AspNetCore.Mvc;

namespace ODPC.Features.Publicaties.PublicatieDetails
{
[ApiController]
public class PublicatieDetailsController : ControllerBase
{
[HttpGet("api/v1/publicaties/{uuid}")]
public IActionResult Get(Guid uuid)
{
return PublicatiesMock.Publicaties.TryGetValue(uuid, out var publicatie)
? Ok(publicatie)
: NotFound();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Microsoft.AspNetCore.Mvc;

namespace ODPC.Features.Publicaties.PublicatieRegistreren
{
[ApiController]
public class PublicatieRegistrerenController : ControllerBase
{
[HttpPost("api/v1/publicaties")]
public IActionResult Post(Publicatie publicatie)
{
publicatie.Uuid = Guid.NewGuid();
publicatie.Creatiedatum = DateOnly.FromDateTime(DateTime.Now);
PublicatiesMock.Publicaties[publicatie.Uuid] = publicatie;
return Ok(publicatie);
}
}
}
25 changes: 25 additions & 0 deletions ODPC.Server/Features/Publicaties/PublicatiesMock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
namespace ODPC.Features.Publicaties
{
public static class PublicatiesMock
{
public static readonly Dictionary<Guid, Publicatie> Publicaties = new Publicatie[]
{
new()
{
Uuid = Guid.NewGuid(),
OfficieleTitel = "Openbaarheid en Verantwoording: De Impact van de Wet open overheid op Bestuurlijke Transparantie",
VerkorteTitel = "Openbaarheid en Verantwoording",
Omschrijving = "",
Creatiedatum = new DateOnly(2024, 08, 24)
},
new()
{
Uuid = Guid.NewGuid(),
OfficieleTitel = "Inzicht voor Iedereen: Toepassing en Resultaten van de Wet open overheid",
VerkorteTitel = "Inzicht voor Iedereen",
Omschrijving = "",
Creatiedatum = new DateOnly(2024, 05, 02)
}
}.ToDictionary(x => x.Uuid);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Microsoft.AspNetCore.Mvc;

namespace ODPC.Features.Publicaties.PublicatiesOverzicht
{
[ApiController]
public class PublicatiesOverzichtController : ControllerBase
{
[HttpGet("api/v1/publicaties")]
public IActionResult Get()
{
return Ok(PublicatiesMock.Publicaties.Values.OrderByDescending(x => x.Creatiedatum));
}
}
}
2 changes: 1 addition & 1 deletion odpc.client/src/features/publicatie/PublicatieDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const publicatie = ref<Publicatie | null>({
});
const { data, isFetching, error, post, put, execute } = useFetchApi(
() => `/api-mock/publicaties${props.id ? "/" + props.id : ""}`,
() => `/api/v1/publicaties${props.id ? "/" + props.id : ""}`,
{ immediate: false }
).json<Publicatie>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import SimpleSpinner from "@/components/SimpleSpinner.vue";
import AlertInline from "@/components/AlertInline.vue";
import type { Publicatie } from "./types";
const { data, isFetching, error } = useFetchApi("/api-mock/publicaties").json<Publicatie[]>();
const { data, isFetching, error } = useFetchApi("/api/v1/publicaties").json<Publicatie[]>();
</script>

<style lang="scss" scoped>
Expand Down

0 comments on commit bf9ce58

Please sign in to comment.