Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

123
Visualizações
Combine Pagination of Two Different Entities With different size

I'm working on a problem where i have to do pagination of two data lists.

ex. psudo code

int recordsPerPage = 100; // this is dynamic
int currentPage = 1; // this is dynamic

array users = [...]; //length = 55
array admins = [....]; //length = 455


i want pagination like this.

perpage = 100;

user_size = 55;
admin_zise = 455;

total_recors = 510 // 455+55

total_pages = Maths.ceil(total_recors/per_page) //5.1 // 6

50 per entity // 100/2

// records will be sent like this.

page 1> 50 user  - 50  admin
page 2> 5  user  - 95  admin
page 3> 0  user  - 100 admin
page 4> 0  user  - 100 admin
page 5> 0  user  - 100 admin
page 6> 0  user  - 10  admin

I'm not able to figure out logic for this case.

I want to implement this is java (spring boot).

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I'm not quite sure what you asking but this might be nearly your question:

@Data
class PaginationResponse {
    private List<Object> data;
    private int sizePerPage;
    private int total;
}

PaginationResponse getResponse(int page, int sizePerPage) {
    List<Object> object = new ArrayList<>();
    ObjectA[] arr_a = {};
    ObjectB[] arr_b = {};

    object.addAll(Arrays.asList(arr_a));
    object.addAll(Arrays.asList(arr_b));

    PaginationResponse response = new PaginationResponse();
    int start = (page - 1) * sizePerPage;
    response.setData(object.subList(start, start + sizePerPage));
    response.setSizePerPage(sizePerPage);
    response.setTotal(object.size());

            return response;
} 
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda