/** * Borrar un elemento * * @param id * @return */ @RequestMapping( method = RequestMethod.DELETE, value = "/data/tipos/{id}", produces = MediaType.APPLICATION_JSON_VALUE) public ReturnAdapter delete(@PathVariable("id") Integer id) { ReturnAdapter result = new ReturnAdapter(); try { result = tipoService.deleteTipo(id); } catch (Exception e) { result = StandardResponse.getResponseInExceptionInt(e, log); } return result; }
/** * Guardar un elemento. * * @param tipo * @return */ @RequestMapping( method = RequestMethod.POST, value = "/data/tipos", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public ReturnAdapter save(@RequestBody Tipo tipo) { ReturnAdapter result = new ReturnAdapter(); try { result = tipoService.saveTipo(tipo); } catch (Exception e) { result = StandardResponse.getResponseInExceptionInt(e, log); } return result; }
@SuppressWarnings({"rawtypes", "unchecked"}) @RequestMapping( method = RequestMethod.GET, value = "/data/tipos", produces = MediaType.APPLICATION_JSON_VALUE) public ReturnAdapter getTipos() { ReturnAdapter result = new ReturnAdapter(); try { List l = tipoService.getTipos(); if (l != null) { result.setNumResult(l.size()); result.setData(l); } else { result.setCode(StandardResponse.SIN_CONTENIDO); result.setMessage(StandardResponse.MESSAGE_SIN_CONTENIDO); result.setNumResult(0); } } catch (Exception e) { result = StandardResponse.getResponseInExceptionInt(e, log); } return result; }
@SuppressWarnings({"rawtypes", "unchecked"}) @RequestMapping( method = RequestMethod.GET, value = "/data/tipos/{id}", produces = MediaType.APPLICATION_JSON_VALUE) public ReturnAdapter getTipoById(@PathVariable("id") Integer id) { ReturnAdapter result = new ReturnAdapter(); try { Tipo l = tipoService.getTipoById(id); if (l != null) { List lista = new ArrayList(); lista.add(l); result.setData(lista); } else { result.setCode(StandardResponse.SIN_CONTENIDO); result.setMessage(StandardResponse.MESSAGE_SIN_CONTENIDO); result.setNumResult(0); } } catch (Exception e) { result = StandardResponse.getResponseInExceptionInt(e, log); } return result; }