Ejemplo n.º 1
0
  @RequestMapping(method = RequestMethod.POST)
  ResponseEntity<?> add(@PathVariable String userId, @RequestBody CoinOrder input) {
    this.validateUser(userId);

    return this.accountRepository
        .findByUsername(userId)
        .map(
            account -> {
              CoinOrder result =
                  coinOrderRepository.save(
                      new CoinOrder(account, input.type, input.quantity, input.priceInCents));

              Link forOneBookmark = new CoinOrderResource(result).getLink("self");

              return ResponseEntity.created(URI.create(forOneBookmark.getHref())).build();
            })
        .orElse(ResponseEntity.noContent().build());
  }