예제 #1
0
 /**
  * PUT /expenses : Updates an existing expense.
  *
  * @param expense the expense to update
  * @return the ResponseEntity with status 200 (OK) and with body the updated expense, or with
  *     status 400 (Bad Request) if the expense is not valid, or with status 500 (Internal Server
  *     Error) if the expense couldnt be updated
  * @throws URISyntaxException if the Location URI syntax is incorrect
  */
 @RequestMapping(
     value = "/expenses",
     method = RequestMethod.PUT,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Expense> updateExpense(@Valid @RequestBody Expense expense)
     throws URISyntaxException {
   log.debug("REST request to update Expense : {}", expense);
   if (expense.getId() == null) {
     return createExpense(expense);
   }
   calculationService.updateExpense(expense);
   Expense result = expenseRepository.save(expense);
   return ResponseEntity.ok()
       .headers(HeaderUtil.createEntityUpdateAlert("expense", expense.getId().toString()))
       .body(result);
 }