Exemplo n.º 1
0
 /** GET /platforms/:id -> get the "id" platform. */
 @RequestMapping(
     value = "/platforms/{id}",
     method = RequestMethod.GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<PlatformDTO> get(@PathVariable String id) {
   log.debug("REST request to get Platform : {}", id);
   return Optional.ofNullable(platformRepository.findOne(id))
       .map(platformMapper::platformToPlatformDTO)
       .map(platformDTO -> new ResponseEntity<>(platformDTO, HttpStatus.OK))
       .orElse(new ResponseEntity<>(HttpStatus.NOT_FOUND));
 }
Exemplo n.º 2
0
  /** DELETE /platforms/:id -> delete the "id" platform. */
  @RequestMapping(
      value = "/platforms/{id}",
      method = RequestMethod.DELETE,
      produces = MediaType.APPLICATION_JSON_VALUE)
  @Timed
  public ResponseEntity<PlatformDTO> delete(@PathVariable String id) {
    log.debug("REST request to delete Platform : {}", id);

    return Optional.ofNullable(platformRepository.findOne(id))
        .map(
            p -> {
              platformRepository.delete(id);
              return p;
            })
        .map(platformMapper::platformToPlatformDTO)
        .map(
            dto ->
                ResponseEntity.ok()
                    .headers(HeaderUtil.createEntityDeletionAlert("platform", id.toString()))
                    .body(dto))
        .orElse(new ResponseEntity<PlatformDTO>(HttpStatus.NOT_FOUND));
  }