コード例 #1
0
ファイル: SocioResource.java プロジェクト: PolGuillen/LigaB
 /** 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));
 }
コード例 #2
0
ファイル: SocioResource.java プロジェクト: PolGuillen/LigaB
 /** 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();
 }
コード例 #3
0
ファイル: SocioResource.java プロジェクト: PolGuillen/LigaB
 /** 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);
 }
コード例 #4
0
ファイル: SocioResource.java プロジェクト: PolGuillen/LigaB
 /** 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);
 }
コード例 #5
0
ファイル: SocioResource.java プロジェクト: PolGuillen/LigaB
 /** 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);
 }