adding pagination for transaction controller
This commit is contained in:
6876
logs/application.2025-07-14.0.log
Normal file
6876
logs/application.2025-07-14.0.log
Normal file
File diff suppressed because it is too large
Load Diff
11340
logs/application.log
11340
logs/application.log
File diff suppressed because it is too large
Load Diff
@@ -7,6 +7,8 @@ import net.kaczmarzyk.spring.data.jpa.web.annotation.Or;
|
|||||||
import net.kaczmarzyk.spring.data.jpa.web.annotation.Spec;
|
import net.kaczmarzyk.spring.data.jpa.web.annotation.Spec;
|
||||||
import net.kaczmarzyk.spring.data.jpa.web.annotation.Conjunction;
|
import net.kaczmarzyk.spring.data.jpa.web.annotation.Conjunction;
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
import zw.qantra.tm.domain.services.TransactionService;
|
import zw.qantra.tm.domain.services.TransactionService;
|
||||||
import zw.qantra.tm.domain.models.Transaction;
|
import zw.qantra.tm.domain.models.Transaction;
|
||||||
|
|
||||||
@@ -16,7 +18,6 @@ import org.springframework.http.ResponseEntity;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import zw.qantra.tm.utils.LogUtils;
|
import zw.qantra.tm.utils.LogUtils;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@@ -28,7 +29,7 @@ public class TransactonController {
|
|||||||
private final TransactionService transactionService;
|
private final TransactionService transactionService;
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public ResponseEntity<List<Transaction>> getAll(
|
public ResponseEntity<Page<Transaction>> getAll(
|
||||||
@Conjunction(value = {
|
@Conjunction(value = {
|
||||||
@Or({
|
@Or({
|
||||||
@Spec(path = "status", spec = Equal.class),
|
@Spec(path = "status", spec = Equal.class),
|
||||||
@@ -54,9 +55,9 @@ public class TransactonController {
|
|||||||
})
|
})
|
||||||
}, and = {
|
}, and = {
|
||||||
@Spec(path = "type", spec = Equal.class),
|
@Spec(path = "type", spec = Equal.class),
|
||||||
@Spec(path = "userId", spec = Equal.class),
|
@Spec(path = "userId", defaultVal = "null", spec = Equal.class),
|
||||||
}) Specification<Transaction> specification) {
|
}) Specification<Transaction> specification, Pageable pageable) {
|
||||||
return ResponseEntity.ok(transactionService.findAll(specification));
|
return ResponseEntity.ok(transactionService.findAll(specification, pageable));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import java.util.UUID;
|
|||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -182,8 +184,8 @@ public class TransactionService {
|
|||||||
return transaction;
|
return transaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Transaction> findAll(Specification<Transaction> spec) {
|
public Page<Transaction> findAll(Specification<Transaction> spec, Pageable pageable) {
|
||||||
return transactionRepository.findAll(spec, Sort.by(Sort.Direction.ASC, "createdAt"));
|
return transactionRepository.findAll(spec, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Transaction save(Transaction transaction){
|
public Transaction save(Transaction transaction){
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public class EcocashRemotePaymentProcessor implements TransactionProcessorInterf
|
|||||||
.action("PAYMENT")
|
.action("PAYMENT")
|
||||||
.sandbox(true)
|
.sandbox(true)
|
||||||
.paymentProcessorLabel("ECOCASH")
|
.paymentProcessorLabel("ECOCASH")
|
||||||
.responseUrl("https://peakapi.stewardpay.co.zw")
|
.responseUrl("https://peakapi.qantra.co.zw")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
|||||||
Reference in New Issue
Block a user