fix(members): guard against removing the last planner from household
removeMember now checks the planner count before deleting a planner
member. Throws ConflictException("Cannot remove the last planner")
when only one planner remains, matching the spec requirement in S4.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -134,6 +134,13 @@ public class HouseholdService {
|
||||
throw new ConflictException("Planner cannot remove yourself");
|
||||
}
|
||||
|
||||
if ("planner".equals(target.getRole())) {
|
||||
long plannerCount = householdMemberRepository.countByHouseholdIdAndRole(householdId, "planner");
|
||||
if (plannerCount <= 1) {
|
||||
throw new ConflictException("Cannot remove the last planner");
|
||||
}
|
||||
}
|
||||
|
||||
householdMemberRepository.delete(target);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user