Implement EditAccount in Backend
This commit is contained in:
@@ -132,6 +132,11 @@ func (*Handler) getAvailableBalance(categories []postgres.GetCategoriesRow, budg
|
||||
return availableBalance
|
||||
}
|
||||
|
||||
type BudgetingResponse struct {
|
||||
Accounts []postgres.GetAccountsWithBalanceRow
|
||||
Budget postgres.Budget
|
||||
}
|
||||
|
||||
func (h *Handler) budgeting(c *gin.Context) {
|
||||
budgetID := c.Param("budgetid")
|
||||
budgetUUID, err := uuid.Parse(budgetID)
|
||||
@@ -140,6 +145,10 @@ func (h *Handler) budgeting(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
h.returnBudgetingData(c, budgetUUID)
|
||||
}
|
||||
|
||||
func (h *Handler) returnBudgetingData(c *gin.Context, budgetUUID uuid.UUID) {
|
||||
budget, err := h.Service.GetBudget(c.Request.Context(), budgetUUID)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusNotFound, err)
|
||||
@@ -152,10 +161,7 @@ func (h *Handler) budgeting(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
data := struct {
|
||||
Accounts []postgres.GetAccountsWithBalanceRow
|
||||
Budget postgres.Budget
|
||||
}{accounts, budget}
|
||||
data := BudgetingResponse{accounts, budget}
|
||||
|
||||
c.JSON(http.StatusOK, data)
|
||||
}
|
||||
|
Reference in New Issue
Block a user