@RequestMapping( value = "/expense", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public ResponseEntity<Void> addExpense(@RequestBody Expense expense, HttpServletRequest request) { expenseService.addExpense(expense); return new ResponseEntity<Void>(HttpStatus.CREATED); }
@RequestMapping( value = "/allExpenses", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public ResponseEntity<List<Expense>> allExpenses(HttpServletRequest request) { List<Expense> newExpense = expenseService.getExpenses(); if (newExpense == null || newExpense.isEmpty()) { return new ResponseEntity<List<Expense>>(HttpStatus.EXPECTATION_FAILED); } return new ResponseEntity<List<Expense>>(newExpense, HttpStatus.OK); }