use of org.springframework.data.domain.Pageable in project sic by belluccifranco.
the class ProductoController method buscarProductos.
@GetMapping("/productos/busqueda/criteria")
@ResponseStatus(HttpStatus.OK)
public Page buscarProductos(@RequestParam long idEmpresa, @RequestParam(required = false) String codigo, @RequestParam(required = false) String descripcion, @RequestParam(required = false) Long idRubro, @RequestParam(required = false) Long idProveedor, @RequestParam(required = false) boolean soloFantantes, @RequestParam(required = false) Integer pagina, @RequestParam(required = false) Integer tamanio) {
Rubro rubro = null;
if (idRubro != null) {
rubro = rubroService.getRubroPorId(idRubro);
}
Proveedor proveedor = null;
if (idProveedor != null) {
proveedor = proveedorService.getProveedorPorId(idProveedor);
}
if (tamanio == null || tamanio <= 0) {
tamanio = TAMANIO_PAGINA_DEFAULT;
}
if (pagina == null || pagina < 0) {
pagina = 0;
}
Pageable pageable = new PageRequest(pagina, tamanio, new Sort(Sort.Direction.ASC, "descripcion"));
BusquedaProductoCriteria criteria = BusquedaProductoCriteria.builder().buscarPorCodigo((codigo != null && !codigo.isEmpty())).codigo(codigo).buscarPorDescripcion(descripcion != null && !descripcion.isEmpty()).descripcion(descripcion).buscarPorRubro(rubro != null).rubro(rubro).buscarPorProveedor(proveedor != null).proveedor(proveedor).empresa(empresaService.getEmpresaPorId(idEmpresa)).listarSoloFaltantes(soloFantantes).pageable(pageable).build();
return productoService.buscarProductos(criteria);
}
use of org.springframework.data.domain.Pageable in project ocvn by devgateway.
the class OcdsController method ocdsReleases.
/**
* Returns a list of OCDS Releases, order by Id, using pagination
*
* @return the release data
*/
@ApiOperation(value = "Resturns all available releases, filtered by the given criteria.")
@RequestMapping(value = "/api/ocds/release/all", method = { RequestMethod.POST, RequestMethod.GET }, produces = "application/json")
@JsonView(Views.Public.class)
public List<Release> ocdsReleases(@ModelAttribute @Valid final YearFilterPagingRequest releaseRequest) {
Pageable pageRequest = new PageRequest(releaseRequest.getPageNumber(), releaseRequest.getPageSize(), Direction.ASC, "id");
List<Release> find = mongoTemplate.find(query(getYearFilterCriteria(releaseRequest, "planning.bidPlanProjectDateApprove").andOperator(getDefaultFilterCriteria(releaseRequest))).with(pageRequest), Release.class);
return find;
}
Aggregations