poc completed
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
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<Recipient> getAllRecipients() {
|
||||
return recipientRepository.findAll();
|
||||
}
|
||||
|
||||
public List<Recipient> 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<Recipient> searchRecipients(Specification<Recipient> specification) {
|
||||
return recipientRepository.findAll(specification);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user