Commit 6ee2a5fd authored by neo's avatar neo

[dev] add page impl for input

parent 86e6a2a4
package pwc.taxtech.atms.dto.vatdto;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import java.util.ArrayList;
import java.util.List;
@Getter
@Setter
public class RestResponsePage<T> extends PageImpl<T> {
private int number;
private int size;
private int totalPages;
private int numberOfElements;
private long totalElements;
private boolean previousPage;
private boolean first;
private boolean nextPage;
private boolean last;
private List<T> content;
private Sort sort;
public RestResponsePage(List<T> content, Pageable pageable, long total) {
super(content, pageable, total);
}
public RestResponsePage(List<T> content) {
super(content);
}
public RestResponsePage() {
super(new ArrayList<T>());
}
public PageImpl<T> pageImpl() {
return new PageImpl<T>(getContent(), new PageRequest(getNumber(),
getSize(), getSort()), getTotalElements());
}
}
......@@ -21,6 +21,7 @@ import pwc.taxtech.atms.dto.FieldsMapper;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.vatdto.InputInvoice;
import pwc.taxtech.atms.dto.vatdto.InputVATInvoiceDto;
import pwc.taxtech.atms.dto.vatdto.RestResponsePage;
import pwc.taxtech.atms.vat.dpo.InputInvoicePreviewQueryParam;
import pwc.taxtech.atms.vat.entity.InputVatInvoice;
import pwc.taxtech.atms.vat.entity.InputVatInvoiceExample;
......@@ -48,13 +49,13 @@ public class InputInvoiceDataImportServiceImpl extends VatAbstractService {
}
private Page<InputInvoice> get(String code, int period, int page, int size) {
PageImpl<InputInvoice> pageInput = null;
RestResponsePage<InputInvoice> pageInput = null;
try (CloseableHttpClient httpclient = HttpClients.createDefault();) {
HttpGet httpget = new HttpGet("http://localhost:8089/input_invoices?page=" + page + "&size=" + size
+ "&code=" + code + "&period=" + period);
try (CloseableHttpResponse response = httpclient.execute(httpget)) {
String inputStr = EntityUtils.toString(response.getEntity());
pageInput = JSONObject.parseObject(inputStr, new TypeReference<PageImpl<InputInvoice>>() {
pageInput = JSONObject.parseObject(inputStr, new TypeReference<RestResponsePage<InputInvoice>>() {
}.getType());
}
} catch (IOException e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment