Add expense/income deletion
This commit is contained in:
@@ -98,4 +98,9 @@ public class ExpenseController {
|
|||||||
if (!categories.isEmpty()) return ResponseEntity.ok(categories);
|
if (!categories.isEmpty()) return ResponseEntity.ok(categories);
|
||||||
else return ResponseEntity.notFound().build();
|
else return ResponseEntity.notFound().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/expenses/{id}")
|
||||||
|
public void deleteCategory(@PathVariable long id) {
|
||||||
|
expenseService.deleteExpenseById(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -96,4 +96,9 @@ public class IncomeController {
|
|||||||
if (!categories.isEmpty()) return ResponseEntity.ok(categories);
|
if (!categories.isEmpty()) return ResponseEntity.ok(categories);
|
||||||
else return ResponseEntity.notFound().build();
|
else return ResponseEntity.notFound().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/incomes/{id}")
|
||||||
|
public void deleteIncome(@PathVariable long id) {
|
||||||
|
incomeService.deleteIncomeById(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -40,4 +40,8 @@ public class ExpenseService implements ITransactionService {
|
|||||||
public Expense getTransactionById(long id) {
|
public Expense getTransactionById(long id) {
|
||||||
return expenseRepository.findById(id).orElse(null);
|
return expenseRepository.findById(id).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void deleteExpenseById(long id) {
|
||||||
|
expenseRepository.deleteById(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -40,4 +40,8 @@ public class IncomeService implements ITransactionService {
|
|||||||
public Income getTransactionById(long id) {
|
public Income getTransactionById(long id) {
|
||||||
return incomeRepository.findById(id).orElse(null);
|
return incomeRepository.findById(id).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void deleteIncomeById(long id) {
|
||||||
|
incomeRepository.deleteById(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user