diff --git a/src/main/java/org/soapService/Repository/AccountVerificationRequestRepository.java b/src/main/java/org/soapService/Repository/AccountVerificationRequestRepository.java index a7e65b13ef013bd12eb821ddda841c84d85b69c4..a686882e6f6b297286d0d9219b35ed2e81a5551a 100644 --- a/src/main/java/org/soapService/Repository/AccountVerificationRequestRepository.java +++ b/src/main/java/org/soapService/Repository/AccountVerificationRequestRepository.java @@ -70,19 +70,23 @@ public class AccountVerificationRequestRepository implements BaseRepository<Acco pageSize = Math.max(pageSize, 1); int offset = pageSize * (page - 1); String query = "SELECT id, uuid, user_id, status, created_at, updated_at FROM account_verification_requests WHERE status = ? LIMIT ? OFFSET ?"; - String totalPageQuery = "SELECT COUNT(*) AS total_page FROM account_verification_requests"; + String totalPageQuery = "SELECT COUNT(*) AS total_page FROM account_verification_requests WHERE status = ?"; PreparedStatement ps = conn.prepareStatement(query); PreparedStatement totalPagePs = conn.prepareStatement(totalPageQuery); ps.setString(1, status); ps.setInt(2, pageSize); ps.setInt(3, offset); + totalPagePs.setString(1, status); + ResultSet rs = ps.executeQuery(); ResultSet totalPageRs = totalPagePs.executeQuery(); int totalPage = 0; while (totalPageRs.next()) { totalPage = (int) Math.ceil((double) totalPageRs.getInt(1) / pageSize); + System.out.println("Total page " + totalPage); + System.out.println("Total page rs " + totalPageRs.getInt(1)); } List<AccountVerificationRequest> rows = new ArrayList<>(); diff --git a/src/main/java/org/soapService/Repository/CatalogReqeustRepository.java b/src/main/java/org/soapService/Repository/CatalogReqeustRepository.java index aa26dd9386562afd37ec13ec76c3093ceebe7320..4fb613c91cb5ffba99fc684c3d874fefcb5596ba 100644 --- a/src/main/java/org/soapService/Repository/CatalogReqeustRepository.java +++ b/src/main/java/org/soapService/Repository/CatalogReqeustRepository.java @@ -44,7 +44,9 @@ public class CatalogReqeustRepository implements BaseRepository<CatalogRequest> ResultSet countRs = countPs.executeQuery(); int totalPage = 0; while (countRs.next()) { - totalPage = countRs.getInt(1) / pageSize + 1; + totalPage = (int) Math.ceil((double) countRs.getInt(1) / pageSize); + System.out.println("Total page " + totalPage); + System.out.println("Total page rs " + countRs.getInt(1)); } List<CatalogRequest> rows = new ArrayList<>(); diff --git a/src/main/java/org/soapService/Services/CatalogRequestService.java b/src/main/java/org/soapService/Services/CatalogRequestService.java index 9cc9bf634d82201689d34605cee3aa6e8c11e2bc..e4b903653b75be5d655f127005ac221462581fc0 100644 --- a/src/main/java/org/soapService/Services/CatalogRequestService.java +++ b/src/main/java/org/soapService/Services/CatalogRequestService.java @@ -2,6 +2,7 @@ package org.soapService.Services; import org.soapService.Common.ServiceResponse; import org.soapService.Domain.CatalogRequest; +import org.soapService.Domain.GetAllResponse; import javax.activation.DataHandler; import javax.jws.HandlerChain; @@ -25,7 +26,7 @@ public interface CatalogRequestService { @WebMethod(operationName = "GetRequests") @RequestWrapper(className = "CatalogRequestService.GetRequests") - public ServiceResponse<CatalogRequest> getCatalogRequests(@WebParam(name = "page") Integer page, @WebParam(name = "pageSize") Integer pageSize) throws SOAPFaultException; + public ServiceResponse<GetAllResponse<CatalogRequest>> getCatalogRequests(@WebParam(name = "page") Integer page, @WebParam(name = "pageSize") Integer pageSize) throws SOAPFaultException; @WebMethod(operationName = "GetRequest") @RequestWrapper(className = "CatalogRequestService.GetRequest") diff --git a/src/main/java/org/soapService/Services/CatalogRequestServiceImpl.java b/src/main/java/org/soapService/Services/CatalogRequestServiceImpl.java index a01814eea19614fb98d39f22c0e452c1134e8570..0880eb85fa91d712d18613c2e0c9805a67b0b392 100644 --- a/src/main/java/org/soapService/Services/CatalogRequestServiceImpl.java +++ b/src/main/java/org/soapService/Services/CatalogRequestServiceImpl.java @@ -24,7 +24,7 @@ public class CatalogRequestServiceImpl extends BaseService implements CatalogReq private static CatalogReqeustRepository catalogRepository = new CatalogReqeustRepository(); private static CatalogValidation catalogValidation = new CatalogValidation(); - public ServiceResponse<CatalogRequest> getCatalogRequests(Integer page, Integer pageSize) throws SOAPFaultException { + public ServiceResponse<GetAllResponse<CatalogRequest>> getCatalogRequests(Integer page, Integer pageSize) throws SOAPFaultException { if (page == null) { page = 1; } @@ -47,12 +47,13 @@ public class CatalogRequestServiceImpl extends BaseService implements CatalogReq response.setData(lcr); lcr.forEach((item) -> { + System.out.print(item.getPage()); item.getData().forEach((data) -> { System.out.println(data.getId()); }); }); - return null; + return response; } public ServiceResponse<CatalogRequest> getCatalogRequest(int requestId) throws SOAPFaultException {