fixed a bug in sushilite/getReportResults
This commit is contained in:
parent
c69a7d51a8
commit
5b4f9bae51
|
@ -85,16 +85,18 @@ public class SushiliteApiImpl implements SushiliteApi {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check remote api's response
|
||||||
System.out.println("sushi responded status " + resp.getStatusCode());
|
System.out.println("sushi responded status " + resp.getStatusCode());
|
||||||
|
|
||||||
|
// get the items corresponding to the requested page
|
||||||
List<ReportItem> requestedItemList = new ArrayList<>();
|
List<ReportItem> requestedItemList = new ArrayList<>();
|
||||||
if (resp.getBody().getReportResponse().getReportWrapper().getReport().getCustomer().getReportItems() != null) {
|
if (resp.getBody().getReportResponse().getReportWrapper().getReport().getCustomer().getReportItems() != null) {
|
||||||
try {
|
try {
|
||||||
int totalItems = resp.getBody().getReportResponse().getReportWrapper().getReport().getCustomer().getReportItems().size();
|
int totalItems = resp.getBody().getReportResponse().getReportWrapper().getReport().getCustomer().getReportItems().size();
|
||||||
int offset = Integer.parseInt(page);
|
|
||||||
int size = Integer.parseInt(pageSize);
|
int size = Integer.parseInt(pageSize);
|
||||||
|
int offset = Integer.parseInt(page)*size;
|
||||||
|
|
||||||
if (offset <= (totalItems / size) ) {
|
if (offset < totalItems ) {
|
||||||
int upperIndex = offset+size;
|
int upperIndex = offset+size;
|
||||||
if (upperIndex > totalItems) {
|
if (upperIndex > totalItems) {
|
||||||
upperIndex = totalItems;
|
upperIndex = totalItems;
|
||||||
|
|
Loading…
Reference in New Issue