Exemplo n.º 1
0
 /** GET /socios/:id -> get the "id" socio. */
 @RequestMapping(
     value = "/socios/{id}",
     method = RequestMethod.GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Socio> get(@PathVariable Long id) {
   log.debug("REST request to get Socio : {}", id);
   return Optional.ofNullable(socioRepository.findOneWithEagerRelationships(id))
       .map(socio -> new ResponseEntity<>(socio, HttpStatus.OK))
       .orElse(new ResponseEntity<>(HttpStatus.NOT_FOUND));
 }
Exemplo n.º 2
0
 /** DELETE /socios/:id -> delete the "id" socio. */
 @RequestMapping(
     value = "/socios/{id}",
     method = RequestMethod.DELETE,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Void> delete(@PathVariable Long id) {
   log.debug("REST request to delete Socio : {}", id);
   socioRepository.delete(id);
   return ResponseEntity.ok()
       .headers(HeaderUtil.createEntityDeletionAlert("socio", id.toString()))
       .build();
 }
Exemplo n.º 3
0
 /** GET /socios -> get all the socios. */
 @RequestMapping(
     value = "/socios",
     method = RequestMethod.GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<List<Socio>> getAll(
     @RequestParam(value = "page", required = false) Integer offset,
     @RequestParam(value = "per_page", required = false) Integer limit)
     throws URISyntaxException {
   Page<Socio> page = socioRepository.findAll(PaginationUtil.generatePageRequest(offset, limit));
   HttpHeaders headers =
       PaginationUtil.generatePaginationHttpHeaders(page, "/api/socios", offset, limit);
   return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
 }
Exemplo n.º 4
0
 /** PUT /socios -> Updates an existing socio. */
 @RequestMapping(
     value = "/socios",
     method = RequestMethod.PUT,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Socio> update(@Valid @RequestBody Socio socio) throws URISyntaxException {
   log.debug("REST request to update Socio : {}", socio);
   if (socio.getId() == null) {
     return create(socio);
   }
   Socio result = socioRepository.save(socio);
   return ResponseEntity.ok()
       .headers(HeaderUtil.createEntityUpdateAlert("socio", socio.getId().toString()))
       .body(result);
 }
Exemplo n.º 5
0
 /** POST /socios -> Create a new socio. */
 @RequestMapping(
     value = "/socios",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Socio> create(@Valid @RequestBody Socio socio) throws URISyntaxException {
   log.debug("REST request to save Socio : {}", socio);
   if (socio.getId() != null) {
     return ResponseEntity.badRequest()
         .header("Failure", "A new socio cannot already have an ID")
         .body(null);
   }
   Socio result = socioRepository.save(socio);
   return ResponseEntity.created(new URI("/api/socios/" + result.getId()))
       .headers(HeaderUtil.createEntityCreationAlert("socio", result.getId().toString()))
       .body(result);
 }