You've already forked reloading-manager
I'll explain when you're older!
This commit is contained in:
@@ -3,6 +3,7 @@ package primers
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.siteworxpro.com/reloading-manager/backend/database"
|
||||
"git.siteworxpro.com/reloading-manager/backend/handlers"
|
||||
"git.siteworxpro.com/reloading-manager/backend/models/primers"
|
||||
@@ -45,9 +46,9 @@ func Post(c echo.Context) error {
|
||||
|
||||
if c.Param("id") != "" {
|
||||
id := c.Param("id")
|
||||
uid := handlers.ParseUuidOrBadRequest(c, id)
|
||||
if uid == nil {
|
||||
return nil
|
||||
uid, err := handlers.ParseUuidOrBadRequest(c, id)
|
||||
if err != nil || uid == nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "Invalid UUID.")
|
||||
}
|
||||
|
||||
p, err := db.Primer.GetPrimerById(context.Background(), *uid)
|
||||
@@ -60,9 +61,9 @@ func Post(c echo.Context) error {
|
||||
}
|
||||
|
||||
if c.FormValue("manufacturer_id") != "" {
|
||||
mid := handlers.ParseUuidOrBadRequest(c, c.FormValue("manufacturer_id"))
|
||||
if mid == nil {
|
||||
return nil
|
||||
mid, err := handlers.ParseUuidOrBadRequest(c, c.FormValue("manufacturer_id"))
|
||||
if err != nil || mid == nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "Invalid Manufacturer ID.")
|
||||
}
|
||||
|
||||
p.ManufacturerID = *mid
|
||||
@@ -121,9 +122,9 @@ func Post(c echo.Context) error {
|
||||
|
||||
newUuid := uuid.New().String()
|
||||
uid, _ := handlers.ParseUuid(newUuid)
|
||||
mid := handlers.ParseUuidOrBadRequest(c, manufacturerId)
|
||||
if mid == nil {
|
||||
return nil
|
||||
mid, err := handlers.ParseUuidOrBadRequest(c, manufacturerId)
|
||||
if err != nil || mid == nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "Invalid Manufacturer ID.")
|
||||
}
|
||||
|
||||
err = db.Primer.InsertPrimer(context.Background(), primers.InsertPrimerParams{
|
||||
@@ -155,9 +156,9 @@ func Photo(c echo.Context) error {
|
||||
}()
|
||||
|
||||
id := c.Param("id")
|
||||
uid := handlers.ParseUuidOrBadRequest(c, id)
|
||||
if uid == nil {
|
||||
return nil
|
||||
uid, err := handlers.ParseUuidOrBadRequest(c, id)
|
||||
if err != nil || uid == nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "Invalid UUID.")
|
||||
}
|
||||
|
||||
byId, err := db.Primer.GetPrimerById(context.Background(), *uid)
|
||||
@@ -185,14 +186,14 @@ func Get(c echo.Context) error {
|
||||
|
||||
if c.Param("id") != "" {
|
||||
id := c.Param("id")
|
||||
uid := handlers.ParseUuidOrBadRequest(c, id)
|
||||
if uid == nil {
|
||||
return nil
|
||||
uid, err := handlers.ParseUuidOrBadRequest(c, id)
|
||||
if err != nil || uid == nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "Invalid UUID.")
|
||||
}
|
||||
|
||||
row, err := db.Primer.GetPrimerById(context.Background(), *uid)
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("primer not found: %v", err)
|
||||
}
|
||||
|
||||
return c.JSON(http.StatusOK, handlers.Response[PrimerResponse]{
|
||||
|
||||
Reference in New Issue
Block a user