Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

119
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda