Is it possible, to somehow alter the code below, so in case of no status
value provided to return all the PaymentLog objects stored in the database instead of only the ones with status
equal with 404
? Basically, I would like if the status
variable has not been provided to call another method in the service layer logService.getAllPaymentLogs()
@GetMapping(Endpoints.LOGS.PAYMENT_LOGS)
public Page<PaymentLog> getPaymentLog(@RequestParam Optional<Integer> status) {
return logService.getPaymentLogStatus(status.orElse(404), PageRequest.of(0, 10));
}
These are the getPaymentLogStatus()
and getAllPaymentLogs
@Override
public Page<PaymentLog> getPaymentLog(Pageable pageable) {
return paymentLogRepository.getAllBy(pageable);
}
And
@Override
public Page<PaymentLog> getPaymentLog(int status, Pageable pageable) {
return paymentLogRepository.getAllByStatus(status, pageable);
}