From a43eccadeb874607018ed9073456af4fb96e9b82 Mon Sep 17 00:00:00 2001 From: effe Date: Sat, 14 Sep 2024 14:17:45 -0400 Subject: [PATCH] refactor: PersonFacade --- .../munera/facades/PersonFacade.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/main/java/com/application/munera/facades/PersonFacade.java b/src/main/java/com/application/munera/facades/PersonFacade.java index b3bc7dd..8339417 100644 --- a/src/main/java/com/application/munera/facades/PersonFacade.java +++ b/src/main/java/com/application/munera/facades/PersonFacade.java @@ -14,6 +14,7 @@ import org.springframework.stereotype.Component; import java.math.BigDecimal; import java.util.List; import java.util.Objects; +import java.util.Optional; @Component public class PersonFacade { @@ -38,6 +39,37 @@ public class PersonFacade { return Objects.requireNonNull(personService.findByUsername(user.getUsername())); } + /** + * Finds a {@link Person} entity by its ID. + * + * @param id the ID of the person to find + * @return an {@link Optional} containing the person if found, or an empty {@link Optional} if not found + */ + public Optional findById(Long id) { + return this.personService.findById(id); + } + + /** + * Updates the details of a {@link Person} entity and associates it with a specific user. + * This method will save the updated person details and associate it with the given user ID. + * + * @param person the {@link Person} entity to update + * @param userId the ID of the user associated with the person + */ + public void update(Person person, Long userId) { + this.personService.update(person, userId); + } + + /** + * Deletes a {@link Person} entity by its ID. + * This method removes the person from the system based on the provided ID. + * + * @param id the ID of the person to delete + */ + public void delete(Long id) { + this.personService.delete(id); + } + /** * Finds all {@code Person} entities associated with the logged-in user, excluding the logged-in user. *