You've already forked reloading-manager
simplify ID validity checks in LoadById function
This commit is contained in:
@@ -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")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user