Aanbod: categorieën als CMS-data met CRUD-routes en categoryId op het aanbod
Nieuwe tabel OfferingsCategories (unieke naam, case-insensitief) en nullable Offering.CategoryId met FK Restrict (migratie AddOfferingCategories). Routes onder /offerings/categories zijn AdminOnly; verwijderen van een gebruikte categorie geeft 409. Het aanbod neemt categoryId (moet bestaan, anders 400) en geeft category (naam) en categoryId terug; niets wordt geseed. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
- **Feature Slug**: contact-forms-module
|
||||
- **Project Type**: Brownfield
|
||||
- **Start Date**: 2026-11-09
|
||||
- **Current Stage**: CONSTRUCTION - CMS-U0 built and committed (awaiting review); next CMS-U1 v2
|
||||
- **Current Stage**: CONSTRUCTION - CMS-U1 built and committed (awaiting review); next CMS-U1b
|
||||
- **Branch**: feature/contact-forms-module (worktree ..SlpModularCms-contact-forms, from master d9cc539; main checkout stays on feature/identity-email-notifications — never switch it)
|
||||
|
||||
## Workspace State
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
# CMS-U1 offerings-category (v2, categories are CMS data): code summary
|
||||
|
||||
## Data
|
||||
OfferingCategory (Id, Name unique case-insensitive, SortOrder, CreatedAt, UpdatedAt) in table OfferingsCategories; Offering.CategoryId (nullable, FK Restrict) + navigation. Migration 20261109193305_AddOfferingCategories (Offerings context). Verified on a real MariaDB: applies after InitialCreate and AddOfferingSlug, unique index rejects 'websites' when 'Websites' exists, FK delete rule RESTRICT. Nothing is seeded.
|
||||
|
||||
## Routes (/api/v1/offerings/categories, class AdminOnly, no anonymous action, no admin segment)
|
||||
GET list {id,name,sortOrder,offeringCount}; POST {name} 201+Location (409 duplicate name); PUT {id:guid} rename (404 unknown, 409 duplicate); DELETE {id:guid} (404 unknown, 409 ProblemDetails while live offerings use it; soft-deleted offerings are released in the same transaction).
|
||||
Offerings: create/update take categoryId (Guid?, must exist, else 400 errors.categoryId=["invalid"], null clears). OfferingDto gains categoryId (string|null) and category (name|null).
|
||||
|
||||
## Handoff for the SLP site
|
||||
GET /api/v1/offerings: category is the name or null (shape unchanged for the site); categoryId and displayOrder are additive fields that the site ignores. A rename is visible on the next request: the name is read through the FK on every query, and the code has no response or output caching. A reverse proxy cache (nginx/IIS) is outside this repo and must not cache /api/v1/offerings for longer than acceptable for renames.
|
||||
|
||||
## Handoff for CMS-U1b (admin UI)
|
||||
Use the four category routes above plus categoryId on offering create/update; offeringCount is in the list for the delete dialog; the 409 delete message is the ProblemDetails title.
|
||||
|
||||
## Dropped from v1
|
||||
Offerings:Categories, OfferingsOptions, appsettings values, legacy-value rule, string column and its migration (v1 stays in git stash until this commit exists).
|
||||
|
||||
## Verification (real output)
|
||||
Build 0 errors. Offerings.Tests 84 passed; Core.Tests 196; Availability.Tests 82; Identity.Tests 37; Master.Tests 57; Api.Tests 4 passed (MariaDB container, removed afterwards). Note: Api.Tests host (SlpModularCms.Api) does not load the Offerings module; the migration was therefore verified separately with dotnet ef database update against the container.
|
||||
|
||||
## Tech debt note
|
||||
prettier --check reports style warnings on 15 pre-existing files in frontend/src/features/offerings (untouched, probably line endings). Not addressed in this feature.
|
||||
+10
-10
@@ -24,16 +24,16 @@ Route `categories` cannot clash with `{id:guid}` on `/offerings`. Ordering/reord
|
||||
- Single `OfferingDto` (from CMS-U0) gains `CategoryId` (Guid?, string in JSON like `Id`) and `Category` (name | null). Public JSON therefore carries `category` as the name or `null` (unchanged shape for the SLS frontend) plus the additive `categoryId`/`displayOrder`.
|
||||
|
||||
## Steps
|
||||
- [ ] **Step 1 — Revert v1 leftovers**: confirm the working tree only contains CMS-U0 (stash holds v1); delete nothing committed.
|
||||
- [ ] **Step 2 — Entities + DbContext**: `OfferingCategory`, `Offering.CategoryId` + navigation, mapping, unique index, FK Restrict; `Include` the category in `OfferingRepository` reads.
|
||||
- [ ] **Step 3 — Repository**: `IOfferingCategoryRepository` (list with usage counts, get, add, remove, exists-by-name case-insensitive, clear category on soft-deleted offerings); transaction support as in `OfferingRepository`.
|
||||
- [ ] **Step 4 — Services**: `IOfferingCategoriesService` (list/create/rename/delete with the rules above; exceptions `OfferingCategoryNameConflictException`, `OfferingCategoryInUseException`); `OfferingsService` validates `CategoryId` exists and maps `CategoryId`/`Category` into `OfferingDto`.
|
||||
- [ ] **Step 5 — Controllers**: `OfferingCategoriesController` (route `offerings/categories`, class-level `AdminOnly`) with ProblemDetails mapping (409 conflict, 409 in-use, 404, 400); `OfferingsController` handles invalid `categoryId` as 400.
|
||||
- [ ] **Step 6 — Migration** `AddOfferingCategories`.
|
||||
- [ ] **Step 7 — Tests (Offerings.Tests)**: category service (create trims, duplicate case-insensitive => conflict, rename conflict, rename unknown, delete in use => in-use, delete unused ok, delete clears soft-deleted references, list with counts and order); offering service (unknown `categoryId` => invalid, null clears, DTO carries id+name, rename visible through DTO); controller mapping (201/404/409/400); repository (FK round trip, case-insensitive exists); route-table test from CMS-U0 extended (all `categories` actions AdminOnly, none anonymous).
|
||||
- [ ] **Step 8 — Build + test (automatic)**: solution build; Offerings.Tests, Core.Tests, Availability.Tests; `Api.Tests` needs a local MySQL (fails here with "connection refused" regardless of the change). Report real output.
|
||||
- [ ] **Step 9 — Docs/handoff**: summary + handoff note for the SLS frontend (public `category` = name|null; additive `categoryId`) and for CMS-U1b (route list above).
|
||||
- [ ] **Step 10 — Commit** (one commit, no push).
|
||||
- [x] **Step 1 — Revert v1 leftovers**: confirm the working tree only contains CMS-U0 (stash holds v1); delete nothing committed.
|
||||
- [x] **Step 2 — Entities + DbContext**: `OfferingCategory`, `Offering.CategoryId` + navigation, mapping, unique index, FK Restrict; `Include` the category in `OfferingRepository` reads.
|
||||
- [x] **Step 3 — Repository**: `IOfferingCategoryRepository` (list with usage counts, get, add, remove, exists-by-name case-insensitive, clear category on soft-deleted offerings); transaction support as in `OfferingRepository`.
|
||||
- [x] **Step 4 — Services**: `IOfferingCategoriesService` (list/create/rename/delete with the rules above; exceptions `OfferingCategoryNameConflictException`, `OfferingCategoryInUseException`); `OfferingsService` validates `CategoryId` exists and maps `CategoryId`/`Category` into `OfferingDto`.
|
||||
- [x] **Step 5 — Controllers**: `OfferingCategoriesController` (route `offerings/categories`, class-level `AdminOnly`) with ProblemDetails mapping (409 conflict, 409 in-use, 404, 400); `OfferingsController` handles invalid `categoryId` as 400.
|
||||
- [x] **Step 6 — Migration** `AddOfferingCategories`.
|
||||
- [x] **Step 7 — Tests (Offerings.Tests)**: category service (create trims, duplicate case-insensitive => conflict, rename conflict, rename unknown, delete in use => in-use, delete unused ok, delete clears soft-deleted references, list with counts and order); offering service (unknown `categoryId` => invalid, null clears, DTO carries id+name, rename visible through DTO); controller mapping (201/404/409/400); repository (FK round trip, case-insensitive exists); route-table test from CMS-U0 extended (all `categories` actions AdminOnly, none anonymous).
|
||||
- [x] **Step 8 — Build + test (automatic)**: solution build; Offerings.Tests, Core.Tests, Availability.Tests; `Api.Tests` needs a local MySQL (fails here with "connection refused" regardless of the change). Report real output.
|
||||
- [x] **Step 9 — Docs/handoff**: summary + handoff note for the SLS frontend (public `category` = name|null; additive `categoryId`) and for CMS-U1b (route list above).
|
||||
- [x] **Step 10 — Commit** (one commit, no push).
|
||||
|
||||
## Explicitly NOT touched
|
||||
Core, Availability, Identity, host config/appsettings (no `Offerings:Categories` anymore), the marker (CMS-U2), OpenAPI export (CMS-U3), frontend (CMS-U1b).
|
||||
|
||||
Reference in New Issue
Block a user