Class BudgetController
java.lang.Object
com.omarigrant.budget.controller.api.BudgetController
Rest Controller for handling the api for Budgets
- Author:
- Omari Grant
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetAllBudgets(org.springframework.security.oauth2.jwt.Jwt jwt) Get a list of Budgets for a authenicated userGet a single budgetpostCalculateBudget(BudgetInputDTO budgetInputDTO) Show the results of a calculation from a given input, without authentication or saving.voidpostDeleteBudget(Long id, org.springframework.security.oauth2.jwt.Jwt jwt) Delete budgetpostSaveBudget(BudgetInputDTO budgetInputDTO, org.springframework.security.oauth2.jwt.Jwt jwt) Show the results of a calculation from a given input and save itpostUpdateBudget(Long id, BudgetInputDTO budgetInputDTO, org.springframework.security.oauth2.jwt.Jwt jwt) Update the budget from a given input and save it
-
Constructor Details
-
BudgetController
public BudgetController()
-
-
Method Details
-
postCalculateBudget
@PostMapping("/budget/calculate") public BudgetDTO postCalculateBudget(@RequestBody BudgetInputDTO budgetInputDTO) Show the results of a calculation from a given input, without authentication or saving.- Parameters:
budgetInputDTO- The model used to retrieve input- Returns:
- BudgetDTO to api in JSON
-
postSaveBudget
@PostMapping("/budget/create") public BudgetDTO postSaveBudget(@RequestBody BudgetInputDTO budgetInputDTO, @AuthenticationPrincipal org.springframework.security.oauth2.jwt.Jwt jwt) Show the results of a calculation from a given input and save it- Parameters:
budgetInputDTO- The model used to retrieve inputjwt- JWT token used to authenticate- Returns:
- BudgetDTO to api in JSON
-
getAllBudgets
@GetMapping("/budget/all") public List<BudgetDTO> getAllBudgets(@AuthenticationPrincipal org.springframework.security.oauth2.jwt.Jwt jwt) Get a list of Budgets for a authenicated user- Parameters:
jwt- JWT token used to authenticate- Returns:
- all BudgetDTOs
-
postDeleteBudget
@GetMapping("/budget/delete/{id}") public void postDeleteBudget(@PathVariable(name="id") Long id, @AuthenticationPrincipal org.springframework.security.oauth2.jwt.Jwt jwt) Delete budget- Parameters:
id- The budget id to be deletedjwt- JWT token used to authenticate
-
getBudget
@GetMapping("/budget/{id}") public BudgetDTO getBudget(@PathVariable(name="id") Long id, @AuthenticationPrincipal org.springframework.security.oauth2.jwt.Jwt jwt) Get a single budget- Parameters:
id- id of budgetjwt- JWT token used to authenticate- Returns:
-
postUpdateBudget
@PostMapping("/budget/update/{id}") public BudgetDTO postUpdateBudget(@PathVariable(name="id") Long id, @RequestBody BudgetInputDTO budgetInputDTO, @AuthenticationPrincipal org.springframework.security.oauth2.jwt.Jwt jwt) Update the budget from a given input and save it- Parameters:
id- id of budgetbudgetInputDTO- The model used to retrieve inputjwt- JWT token used to authenticate- Returns:
- BudgetDTO to api in JSON
-