You've already forked reloading-manager
fix tpyo (#8)
Reviewed-on: Siteworxpro/reloading-manager#8 Co-authored-by: Ron Rise <ron@siteworxpro.com> Co-committed-by: Ron Rise <ron@siteworxpro.com>
This commit was merged in pull request #8.
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"
|
||||
@@ -19,7 +20,9 @@ type PrimerResponse struct {
|
||||
|
||||
func Delete(c echo.Context) error {
|
||||
db := c.(*database.CustomContext).Db
|
||||
defer db.Db.Close(context.Background())
|
||||
defer func() {
|
||||
_ = db.Db.Close(context.Background())
|
||||
}()
|
||||
|
||||
id := c.Param("id")
|
||||
uid, err := handlers.ParseUuid(id)
|
||||
@@ -37,13 +40,15 @@ func Delete(c echo.Context) error {
|
||||
|
||||
func Post(c echo.Context) error {
|
||||
db := c.(*database.CustomContext).Db
|
||||
defer db.Db.Close(context.Background())
|
||||
defer func() {
|
||||
_ = db.Db.Close(context.Background())
|
||||
}()
|
||||
|
||||
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)
|
||||
@@ -56,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
|
||||
@@ -112,13 +117,14 @@ func Post(c echo.Context) error {
|
||||
if metaString == "" {
|
||||
metaString = "{}"
|
||||
}
|
||||
var meta json.RawMessage = []byte(metaString)
|
||||
|
||||
meta := []byte(metaString)
|
||||
|
||||
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{
|
||||
@@ -145,12 +151,14 @@ func Post(c echo.Context) error {
|
||||
|
||||
func Photo(c echo.Context) error {
|
||||
db := c.(*database.CustomContext).Db
|
||||
defer db.Db.Close(context.Background())
|
||||
defer func() {
|
||||
_ = db.Db.Close(context.Background())
|
||||
}()
|
||||
|
||||
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)
|
||||
@@ -172,18 +180,20 @@ func Photo(c echo.Context) error {
|
||||
|
||||
func Get(c echo.Context) error {
|
||||
db := c.(*database.CustomContext).Db
|
||||
defer db.Db.Close(context.Background())
|
||||
defer func() {
|
||||
_ = db.Db.Close(context.Background())
|
||||
}()
|
||||
|
||||
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