Search in sources :

Example 81 with GetMapping

use of org.springframework.web.bind.annotation.GetMapping in project POC by rajadilipkolli.

the class CustomerController method getCustomer.

/**
 * Get customer using id. Returns HTTP 404 if customer not found
 *
 * @param customerId a {@link java.lang.Long} object.
 * @return retrieved customer
 * @throws com.poc.restfulpoc.exception.EntityNotFoundException if any.
 */
@GetMapping(value = "/customers/{customerId}", produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE })
public ResponseEntity<Customer> getCustomer(@PathVariable("customerId") @NotBlank Long customerId) throws EntityNotFoundException {
    log.info("Fetching Customer with id {}", customerId);
    final Customer user = customerService.getCustomer(customerId);
    return new ResponseEntity<>(user, HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) Customer(com.poc.restfulpoc.entities.Customer) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 82 with GetMapping

use of org.springframework.web.bind.annotation.GetMapping in project sic by belluccifranco.

the class PagoController method getPagosPorClienteEntreFechas.

@GetMapping("/pagos/clientes/{idCliente}")
@ResponseStatus(HttpStatus.OK)
public Page<Pago> getPagosPorClienteEntreFechas(@PathVariable long idCliente, @RequestParam(required = false) Long desde, @RequestParam(required = false) Long hasta, @RequestParam(required = false) Integer pagina, @RequestParam(required = false) Integer tamanio) {
    Calendar fechaDesde = Calendar.getInstance();
    Calendar fechaHasta = Calendar.getInstance();
    if ((desde != null) && (hasta != null)) {
        fechaDesde.setTimeInMillis(desde);
        fechaHasta.setTimeInMillis(hasta);
    }
    fechaDesde.set(Calendar.HOUR_OF_DAY, 0);
    fechaDesde.set(Calendar.MINUTE, 0);
    fechaDesde.set(Calendar.SECOND, 0);
    fechaHasta.set(Calendar.HOUR_OF_DAY, 23);
    fechaHasta.set(Calendar.MINUTE, 59);
    fechaHasta.set(Calendar.SECOND, 59);
    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.DESC, "fecha"));
    return pagoService.getPagosPorClienteEntreFechas(idCliente, fechaDesde.getTime(), fechaHasta.getTime(), pageable);
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) Pageable(org.springframework.data.domain.Pageable) Calendar(java.util.Calendar) Sort(org.springframework.data.domain.Sort) GetMapping(org.springframework.web.bind.annotation.GetMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus)

Example 83 with GetMapping

use of org.springframework.web.bind.annotation.GetMapping in project sic by belluccifranco.

the class NotaController method getReporteNota.

@GetMapping("/notas/{idNota}/reporte")
@ResponseStatus(HttpStatus.OK)
public ResponseEntity<byte[]> getReporteNota(@PathVariable long idNota) {
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_PDF);
    Nota nota = notaService.getNotaPorId(idNota);
    String fileName = (nota instanceof NotaCredito) ? "NotaCredito.pdf" : (nota instanceof NotaDebito) ? "NotaDebito.pdf" : "Nota.pdf";
    headers.add("content-disposition", "inline; filename=" + fileName);
    headers.setCacheControl("must-revalidate, post-check=0, pre-check=0");
    byte[] reportePDF = notaService.getReporteNota(nota);
    return new ResponseEntity<>(reportePDF, headers, HttpStatus.OK);
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ResponseEntity(org.springframework.http.ResponseEntity) RenglonNotaDebito(sic.modelo.RenglonNotaDebito) NotaDebito(sic.modelo.NotaDebito) Nota(sic.modelo.Nota) NotaCredito(sic.modelo.NotaCredito) RenglonNotaCredito(sic.modelo.RenglonNotaCredito) GetMapping(org.springframework.web.bind.annotation.GetMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus)

Example 84 with GetMapping

use of org.springframework.web.bind.annotation.GetMapping in project sic by belluccifranco.

the class NotaController method buscarNotasPorClienteYEmpresa.

@GetMapping("/notas/busqueda/criteria")
@ResponseStatus(HttpStatus.OK)
public Page<Nota> buscarNotasPorClienteYEmpresa(@RequestParam(value = "desde", required = false) Long desde, @RequestParam(value = "hasta", required = false) Long hasta, @RequestParam Long idCliente, @RequestParam Long idEmpresa, @RequestParam(required = false) Integer pagina, @RequestParam(required = false) Integer tamanio) {
    Calendar fechaDesde = Calendar.getInstance();
    Calendar fechaHasta = Calendar.getInstance();
    if (desde != null && hasta != null) {
        fechaDesde.setTimeInMillis(desde);
        fechaHasta.setTimeInMillis(hasta);
    }
    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, "fecha"));
    BusquedaNotaCriteria criteria = BusquedaNotaCriteria.builder().buscaPorFecha((desde != null) && (hasta != null)).fechaDesde(fechaDesde.getTime()).fechaHasta(fechaHasta.getTime()).empresa(empresaService.getEmpresaPorId(idEmpresa)).cantidadDeRegistros(0).cliente(clienteService.getClientePorId(idCliente)).pageable(pageable).build();
    return notaService.buscarNotasPorClienteYEmpresa(criteria);
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) Pageable(org.springframework.data.domain.Pageable) Calendar(java.util.Calendar) Sort(org.springframework.data.domain.Sort) BusquedaNotaCriteria(sic.modelo.BusquedaNotaCriteria) GetMapping(org.springframework.web.bind.annotation.GetMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus)

Example 85 with GetMapping

use of org.springframework.web.bind.annotation.GetMapping in project sic by belluccifranco.

the class NotaController method getSaldoNotas.

@GetMapping("/notas/saldo")
@ResponseStatus(HttpStatus.OK)
public double getSaldoNotas(@RequestParam Long hasta, @RequestParam long idCliente, @RequestParam long IdEmpresa) {
    Calendar fechaHasta = Calendar.getInstance();
    fechaHasta.setTimeInMillis(hasta);
    return notaService.getSaldoNotas(fechaHasta.getTime(), idCliente, IdEmpresa);
}
Also used : Calendar(java.util.Calendar) GetMapping(org.springframework.web.bind.annotation.GetMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus)

Aggregations

GetMapping (org.springframework.web.bind.annotation.GetMapping)756 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)114 ResponseEntity (org.springframework.http.ResponseEntity)80 ArrayList (java.util.ArrayList)52 List (java.util.List)49 ModelAndView (org.springframework.web.servlet.ModelAndView)48 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)45 HttpHeaders (org.springframework.http.HttpHeaders)41 Map (java.util.Map)40 HashMap (java.util.HashMap)38 lombok.val (lombok.val)38 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)36 Grid (org.hisp.dhis.common.Grid)35 IOException (java.io.IOException)34 RequestParam (org.springframework.web.bind.annotation.RequestParam)34 ApiOperation (io.swagger.annotations.ApiOperation)31 RootNode (org.hisp.dhis.node.types.RootNode)31 PathVariable (org.springframework.web.bind.annotation.PathVariable)31 HttpServletRequest (javax.servlet.http.HttpServletRequest)30 FieldFilterParams (org.hisp.dhis.fieldfilter.FieldFilterParams)28