simplify ID validity checks in LoadById function
All checks were successful
🧪 ✨ Unit Tests Workflow / 🧪 🐹 GolangCI-Lint (push) Successful in 1m38s
🧪 ✨ Unit Tests Workflow / 🧪 📜 JavaScript Tests (push) Successful in 2m35s
🧪 ✨ Unit Tests Workflow / 🔍 🐹 Go Tests (push) Successful in 3m31s

This commit is contained in:
2025-06-10 21:39:28 -04:00
parent cd874f174f
commit 56e2acfe30

View File

@@ -81,7 +81,7 @@ func Post(c echo.Context) error {
} }
gbi, err := db.Loads.GetLoadById(context.Background(), *uuid) gbi, err := db.Loads.GetLoadById(context.Background(), *uuid)
if err != nil || gbi.ID.Valid == false { if err != nil || !gbi.ID.Valid {
return handlers.NotFound(c, "load not found") return handlers.NotFound(c, "load not found")
} }
@@ -202,7 +202,6 @@ func Photo(c echo.Context) error {
mt, _, _ := mime.ParseMediaType(string(file.Photo)) mt, _, _ := mime.ParseMediaType(string(file.Photo))
return c.Blob(http.StatusOK, mt, file.Photo) return c.Blob(http.StatusOK, mt, file.Photo)
} }
func Get(c echo.Context) error { func Get(c echo.Context) error {
@@ -579,7 +578,7 @@ func Delete(c echo.Context) error {
}() }()
exists, err := db.Loads.GetLoadById(context.Background(), *uuid) exists, err := db.Loads.GetLoadById(context.Background(), *uuid)
if err != nil || exists.ID.Valid == false { if err != nil || !exists.ID.Valid {
return handlers.NotFound(c, "load not found") return handlers.NotFound(c, "load not found")
} }