WEB-0: CMS content model + /api/site-snapshot + Page/Block CRUD

- Entities: Site (singleton, navOrder JSON), Page (slug/title/seoDescription/status enum),
  Block (single table, Type enum + Data JSON; RichText=Markdown), Media. Migration
  AddCmsEntities, seeds 6 Jimdo-mirror pages (placeholder Heading each; abgabetiere also an
  auto AbgabetiereList block) + Site singleton nav.
- GET /api/site-snapshot: one JSON doc (site nav + pages + ordered blocks {id,order,type,data});
  AbgabetiereList(auto) resolved from live ForSale gerbils -> {name, farbschlag, group(=Becken),
  photos[urls], aiSaleText:null} (no price per god). SiteSnapshotService.
- CRUD: GET/POST/PUT/DELETE pages; add/update/delete blocks; PUT .../blocks/order reorder.
  Block type allowlisted by enum; data validated as JSON object.
This commit is contained in:
2026-06-06 09:19:42 +02:00
parent 13ff97a12b
commit 94f055f9bf
9 changed files with 2095 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,141 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace GerbilManagerWebAPI.Migrations
{
/// <inheritdoc />
public partial class AddCmsEntities : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Media",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
FileName = table.Column<string>(type: "text", nullable: false),
Url = table.Column<string>(type: "text", nullable: false),
Alt = table.Column<string>(type: "text", nullable: true),
Width = table.Column<int>(type: "integer", nullable: true),
Height = table.Column<int>(type: "integer", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Media", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Pages",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Slug = table.Column<string>(type: "text", nullable: false),
Title = table.Column<string>(type: "text", nullable: false),
SeoDescription = table.Column<string>(type: "text", nullable: true),
Status = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Pages", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Sites",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
DefaultLocale = table.Column<string>(type: "text", nullable: false),
NavOrder = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Sites", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Blocks",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
PageId = table.Column<Guid>(type: "uuid", nullable: false),
Order = table.Column<int>(type: "integer", nullable: false),
Type = table.Column<string>(type: "text", nullable: false),
Data = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Blocks", x => x.Id);
table.ForeignKey(
name: "FK_Blocks_Pages_PageId",
column: x => x.PageId,
principalTable: "Pages",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.InsertData(
table: "Pages",
columns: new[] { "Id", "SeoDescription", "Slug", "Status", "Title" },
values: new object[,]
{
{ new Guid("51720001-0000-0000-0000-000000000001"), null, "start", "Published", "Startseite" },
{ new Guid("51720001-0000-0000-0000-000000000002"), null, "ueber-die-zucht", "Published", "Über die Zucht" },
{ new Guid("51720001-0000-0000-0000-000000000003"), null, "abgabetiere", "Published", "Abgabetiere" },
{ new Guid("51720001-0000-0000-0000-000000000004"), null, "abgabebedingungen", "Published", "Abgabebedingungen" },
{ new Guid("51720001-0000-0000-0000-000000000005"), null, "farben-genetik", "Published", "Farben & Genetik" },
{ new Guid("51720001-0000-0000-0000-000000000006"), null, "kontakt", "Published", "Kontakt" }
});
migrationBuilder.InsertData(
table: "Sites",
columns: new[] { "Id", "DefaultLocale", "NavOrder" },
values: new object[] { new Guid("5172e000-0000-0000-0000-000000000001"), "de", "[\"51720001-0000-0000-0000-000000000001\",\"51720001-0000-0000-0000-000000000002\",\"51720001-0000-0000-0000-000000000003\",\"51720001-0000-0000-0000-000000000004\",\"51720001-0000-0000-0000-000000000005\",\"51720001-0000-0000-0000-000000000006\"]" });
migrationBuilder.InsertData(
table: "Blocks",
columns: new[] { "Id", "Data", "Order", "PageId", "Type" },
values: new object[,]
{
{ new Guid("51720002-0000-0000-0000-000000000001"), "{\"text\":\"Startseite\",\"level\":1}", 0, new Guid("51720001-0000-0000-0000-000000000001"), "Heading" },
{ new Guid("51720002-0000-0000-0000-000000000002"), "{\"text\":\"Über die Zucht\",\"level\":1}", 0, new Guid("51720001-0000-0000-0000-000000000002"), "Heading" },
{ new Guid("51720002-0000-0000-0000-000000000003"), "{\"text\":\"Abgabetiere\",\"level\":1}", 0, new Guid("51720001-0000-0000-0000-000000000003"), "Heading" },
{ new Guid("51720002-0000-0000-0000-000000000004"), "{\"text\":\"Abgabebedingungen\",\"level\":1}", 0, new Guid("51720001-0000-0000-0000-000000000004"), "Heading" },
{ new Guid("51720002-0000-0000-0000-000000000005"), "{\"text\":\"Farben & Genetik\",\"level\":1}", 0, new Guid("51720001-0000-0000-0000-000000000005"), "Heading" },
{ new Guid("51720002-0000-0000-0000-000000000006"), "{\"text\":\"Kontakt\",\"level\":1}", 0, new Guid("51720001-0000-0000-0000-000000000006"), "Heading" },
{ new Guid("51720002-0000-0000-0000-000000000010"), "{\"mode\":\"auto\",\"intro\":\"\"}", 1, new Guid("51720001-0000-0000-0000-000000000003"), "AbgabetiereList" }
});
migrationBuilder.CreateIndex(
name: "IX_Blocks_PageId",
table: "Blocks",
column: "PageId");
migrationBuilder.CreateIndex(
name: "IX_Pages_Slug",
table: "Pages",
column: "Slug",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Blocks");
migrationBuilder.DropTable(
name: "Media");
migrationBuilder.DropTable(
name: "Sites");
migrationBuilder.DropTable(
name: "Pages");
}
}
}

View File

@@ -21,6 +21,91 @@ namespace GerbilManagerWebAPI.Migrations
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("GerbilManagerWebAPI.Models.Block", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Data")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Order")
.HasColumnType("integer");
b.Property<Guid>("PageId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("PageId");
b.ToTable("Blocks");
b.HasData(
new
{
Id = new Guid("51720002-0000-0000-0000-000000000001"),
Data = "{\"text\":\"Startseite\",\"level\":1}",
Order = 0,
PageId = new Guid("51720001-0000-0000-0000-000000000001"),
Type = "Heading"
},
new
{
Id = new Guid("51720002-0000-0000-0000-000000000002"),
Data = "{\"text\":\"Über die Zucht\",\"level\":1}",
Order = 0,
PageId = new Guid("51720001-0000-0000-0000-000000000002"),
Type = "Heading"
},
new
{
Id = new Guid("51720002-0000-0000-0000-000000000003"),
Data = "{\"text\":\"Abgabetiere\",\"level\":1}",
Order = 0,
PageId = new Guid("51720001-0000-0000-0000-000000000003"),
Type = "Heading"
},
new
{
Id = new Guid("51720002-0000-0000-0000-000000000004"),
Data = "{\"text\":\"Abgabebedingungen\",\"level\":1}",
Order = 0,
PageId = new Guid("51720001-0000-0000-0000-000000000004"),
Type = "Heading"
},
new
{
Id = new Guid("51720002-0000-0000-0000-000000000005"),
Data = "{\"text\":\"Farben & Genetik\",\"level\":1}",
Order = 0,
PageId = new Guid("51720001-0000-0000-0000-000000000005"),
Type = "Heading"
},
new
{
Id = new Guid("51720002-0000-0000-0000-000000000006"),
Data = "{\"text\":\"Kontakt\",\"level\":1}",
Order = 0,
PageId = new Guid("51720001-0000-0000-0000-000000000006"),
Type = "Heading"
},
new
{
Id = new Guid("51720002-0000-0000-0000-000000000010"),
Data = "{\"mode\":\"auto\",\"intro\":\"\"}",
Order = 1,
PageId = new Guid("51720001-0000-0000-0000-000000000003"),
Type = "AbgabetiereList"
});
});
modelBuilder.Entity("GerbilManagerWebAPI.Models.BreederSettings", b =>
{
b.Property<Guid>("Id")
@@ -842,6 +927,107 @@ namespace GerbilManagerWebAPI.Migrations
b.ToTable("Litters");
});
modelBuilder.Entity("GerbilManagerWebAPI.Models.Media", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Alt")
.HasColumnType("text");
b.Property<string>("FileName")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("Height")
.HasColumnType("integer");
b.Property<string>("Url")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("Width")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Media");
});
modelBuilder.Entity("GerbilManagerWebAPI.Models.Page", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("SeoDescription")
.HasColumnType("text");
b.Property<string>("Slug")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("Slug")
.IsUnique();
b.ToTable("Pages");
b.HasData(
new
{
Id = new Guid("51720001-0000-0000-0000-000000000001"),
Slug = "start",
Status = "Published",
Title = "Startseite"
},
new
{
Id = new Guid("51720001-0000-0000-0000-000000000002"),
Slug = "ueber-die-zucht",
Status = "Published",
Title = "Über die Zucht"
},
new
{
Id = new Guid("51720001-0000-0000-0000-000000000003"),
Slug = "abgabetiere",
Status = "Published",
Title = "Abgabetiere"
},
new
{
Id = new Guid("51720001-0000-0000-0000-000000000004"),
Slug = "abgabebedingungen",
Status = "Published",
Title = "Abgabebedingungen"
},
new
{
Id = new Guid("51720001-0000-0000-0000-000000000005"),
Slug = "farben-genetik",
Status = "Published",
Title = "Farben & Genetik"
},
new
{
Id = new Guid("51720001-0000-0000-0000-000000000006"),
Slug = "kontakt",
Status = "Published",
Title = "Kontakt"
});
});
modelBuilder.Entity("GerbilManagerWebAPI.Models.SaleContract", b =>
{
b.Property<Guid>("Id")
@@ -890,6 +1076,33 @@ namespace GerbilManagerWebAPI.Migrations
b.ToTable("SaleContractAnimal");
});
modelBuilder.Entity("GerbilManagerWebAPI.Models.Site", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("DefaultLocale")
.IsRequired()
.HasColumnType("text");
b.Property<string>("NavOrder")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Sites");
b.HasData(
new
{
Id = new Guid("5172e000-0000-0000-0000-000000000001"),
DefaultLocale = "de",
NavOrder = "[\"51720001-0000-0000-0000-000000000001\",\"51720001-0000-0000-0000-000000000002\",\"51720001-0000-0000-0000-000000000003\",\"51720001-0000-0000-0000-000000000004\",\"51720001-0000-0000-0000-000000000005\",\"51720001-0000-0000-0000-000000000006\"]"
});
});
modelBuilder.Entity("GerbilManagerWebAPI.Models.WeightRecord", b =>
{
b.Property<Guid>("Id")
@@ -915,6 +1128,15 @@ namespace GerbilManagerWebAPI.Migrations
b.ToTable("WeightRecords");
});
modelBuilder.Entity("GerbilManagerWebAPI.Models.Block", b =>
{
b.HasOne("GerbilManagerWebAPI.Models.Page", null)
.WithMany("Blocks")
.HasForeignKey("PageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("GerbilManagerWebAPI.Models.Gerbil", b =>
{
b.HasOne("GerbilManagerWebAPI.Models.ColorVariety", "ColorVariety")
@@ -1030,6 +1252,11 @@ namespace GerbilManagerWebAPI.Migrations
b.Navigation("Gerbils");
});
modelBuilder.Entity("GerbilManagerWebAPI.Models.Page", b =>
{
b.Navigation("Blocks");
});
modelBuilder.Entity("GerbilManagerWebAPI.Models.SaleContract", b =>
{
b.Navigation("Animals");