Class BudgetController

java.lang.Object
com.omarigrant.budget.controller.api.BudgetController

@RestController public class BudgetController extends Object
Rest Controller for handling the api for Budgets
Author:
Omari Grant
  • 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 input
      jwt - 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 deleted
      jwt - 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 budget
      jwt - 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 budget
      budgetInputDTO - The model used to retrieve input
      jwt - JWT token used to authenticate
      Returns:
      BudgetDTO to api in JSON