You've already forked gun-manager-backend
I don't know why. Just move on.
This commit is contained in:
@@ -24,6 +24,7 @@ type gunPayload struct {
|
||||
}
|
||||
|
||||
type gunPost struct {
|
||||
Id int64 `json:"id"`
|
||||
Make string `json:"make" validate:"required"`
|
||||
Model string `json:"model" validate:"required"`
|
||||
SerialNumber string `json:"serial_number" validate:"required"`
|
||||
@@ -118,6 +119,57 @@ func DeleteById(c echo.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func UpdateGun(c echo.Context) error {
|
||||
gun := new(gunPost)
|
||||
err := c.Bind(gun)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
getDb := sql.GetDb()
|
||||
err = getDb.Queries.UpdateGun(context.Background(), db.UpdateGunParams{
|
||||
Make: sql2.NullString{
|
||||
String: gun.Make,
|
||||
Valid: true,
|
||||
},
|
||||
Model: sql2.NullString{
|
||||
String: gun.Model,
|
||||
Valid: true,
|
||||
},
|
||||
SerialNumber: sql2.NullString{
|
||||
String: gun.SerialNumber,
|
||||
Valid: true,
|
||||
},
|
||||
PurchaseAmount: sql2.NullInt64{
|
||||
Int64: gun.PurchaseAmount,
|
||||
Valid: true,
|
||||
},
|
||||
ValueAmount: sql2.NullInt64{
|
||||
Int64: gun.ValueAmount,
|
||||
Valid: true,
|
||||
},
|
||||
DatePurchased: sql2.NullString{
|
||||
String: gun.DatePurchased,
|
||||
Valid: true,
|
||||
},
|
||||
Notes: sql2.NullString{
|
||||
String: gun.Notes,
|
||||
Valid: true,
|
||||
},
|
||||
ID: gun.Id,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = c.JSON(http.StatusOK, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetById(c echo.Context) error {
|
||||
id, err := strconv.ParseInt(c.Param("id"), 10, 64)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user