package zw.qantra.tm.domain.services; import lombok.Getter; import lombok.RequiredArgsConstructor; import org.springframework.data.jpa.domain.Specification; import org.springframework.stereotype.Service; import zw.qantra.tm.domain.models.Recipient; import zw.qantra.tm.domain.repositories.RecipientRepository; import java.util.List; import java.util.Optional; import java.util.UUID; @Service @RequiredArgsConstructor public class RecipientService { @Getter private final RecipientRepository recipientRepository; public List getAllRecipients() { return recipientRepository.findAll(); } public List getRecipient(String account, String userId) { return recipientRepository.findByAccountAndUserId(account, userId); } public Recipient save(Recipient recipient) { return recipientRepository.save(recipient); } public Recipient updateRecipient(UUID id, Recipient recipient) { if (recipientRepository.existsById(id)) { recipient.setId(id); return recipientRepository.save(recipient); } return null; } public boolean deleteRecipient(UUID id) { if (recipientRepository.existsById(id)) { recipientRepository.deleteById(id); return true; } return false; } public List searchRecipients(Specification specification) { return recipientRepository.findAll(specification); } }