Implement problematic transactions endpoint
This commit is contained in:
@ -8,6 +8,23 @@ import (
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
func (h *Handler) problematicTransactions(c *gin.Context) {
|
||||
budgetID := c.Param("budgetid")
|
||||
budgetUUID, err := uuid.Parse(budgetID)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
return
|
||||
}
|
||||
|
||||
transactions, err := h.Service.GetProblematicTransactions(c.Request.Context(), budgetUUID)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, TransactionsResponse{nil, transactions})
|
||||
}
|
||||
|
||||
func (h *Handler) transactionsForAccount(c *gin.Context) {
|
||||
accountID := c.Param("accountid")
|
||||
accountUUID, err := uuid.Parse(accountID)
|
||||
@ -28,11 +45,11 @@ func (h *Handler) transactionsForAccount(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, TransactionsResponse{account, transactions})
|
||||
c.JSON(http.StatusOK, TransactionsResponse{&account, transactions})
|
||||
}
|
||||
|
||||
type TransactionsResponse struct {
|
||||
Account postgres.Account
|
||||
Account *postgres.Account
|
||||
Transactions []postgres.DisplayTransaction
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user