feat(person): generation on PersonUpsertCommand + PersonUpdateDTO (#689)
Adds the optional generation field to both DTOs: - PersonUpsertCommand gains Integer generation in the canonical-import builder chain; service wiring lands in the next commit. - PersonUpdateDTO gains @Min(0)@Max(10) Integer generation, the form-path surface. The constraints mirror the V70 CHECK so validation fails fast at the controller before reaching the DB. PersonControllerTest pins the validation behaviour: -1 → 400, 11 → 400, null → 200, 3 → 200 for both PUT (update) and POST (create) paths. The GlobalExceptionHandler maps MethodArgumentNotValidException to VALIDATION_ERROR so the frontend's extractErrorCode keeps working. Refs #689 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package org.raddatz.familienarchiv.person;
|
||||
|
||||
import jakarta.validation.constraints.Max;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
@@ -21,4 +23,9 @@ public class PersonUpdateDTO {
|
||||
private String notes;
|
||||
private Integer birthYear;
|
||||
private Integer deathYear;
|
||||
// Mirror of the persons.generation CHECK constraint (V70).
|
||||
// null clears the field; 0..10 is the allowlist of valid indices.
|
||||
@Min(0)
|
||||
@Max(10)
|
||||
private Integer generation;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ public record PersonUpsertCommand(
|
||||
String notes,
|
||||
Integer birthYear,
|
||||
Integer deathYear,
|
||||
Integer generation,
|
||||
boolean familyMember,
|
||||
PersonType personType,
|
||||
boolean provisional
|
||||
|
||||
Reference in New Issue
Block a user