Continue migration to echo
This commit is contained in:
@ -18,28 +18,24 @@ func (h *Handler) setCategoryAssignment(c echo.Context) error {
|
||||
categoryID := c.Param("categoryid")
|
||||
categoryUUID, err := uuid.Parse(categoryID)
|
||||
if err != nil {
|
||||
c.AbortWithStatusJSON(http.StatusBadRequest, ErrorResponse{"categoryid missing from URL"})
|
||||
return
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "categoryid missing from URL")
|
||||
}
|
||||
|
||||
var request SetCategoryAssignmentRequest
|
||||
err = c.BindJSON(&request)
|
||||
err = c.Bind(&request)
|
||||
if err != nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, fmt.Errorf("invalid payload: %w", err))
|
||||
return
|
||||
}
|
||||
|
||||
date, err := getDate(c)
|
||||
if err != nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, fmt.Errorf("date invalid: %w", err))
|
||||
return
|
||||
}
|
||||
|
||||
var amount numeric.Numeric
|
||||
err = amount.Set(request.Assigned)
|
||||
if err != nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, fmt.Errorf("parse amount: %w", err))
|
||||
return
|
||||
}
|
||||
|
||||
updateArgs := postgres.UpdateAssignmentParams{
|
||||
@ -49,7 +45,8 @@ func (h *Handler) setCategoryAssignment(c echo.Context) error {
|
||||
}
|
||||
err = h.Service.UpdateAssignment(c.Request().Context(), updateArgs)
|
||||
if err != nil {
|
||||
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Errorf("update assignment: %w", err))
|
||||
return
|
||||
return fmt.Errorf("update assignment: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user