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