From b77e47ba7e427e81106e66d7343604766eb901cd Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Thu, 11 Jan 2024 09:39:11 +1100 Subject: [PATCH] test returning created safe details --- controllers/controlSafes.go | 2 +- models/safe.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/controllers/controlSafes.go b/controllers/controlSafes.go index 283a602..cab5c31 100644 --- a/controllers/controlSafes.go +++ b/controllers/controlSafes.go @@ -92,7 +92,7 @@ func AddSafeHandler(c *gin.Context) { return } - c.JSON(http.StatusOK, gin.H{"message": "safe creation success"}) + c.JSON(http.StatusOK, gin.H{"message": "safe creation success", "data": s}) } func DeleteSafeHandler(c *gin.Context) { diff --git a/models/safe.go b/models/safe.go index a3698db..1f59f29 100644 --- a/models/safe.go +++ b/models/safe.go @@ -107,6 +107,7 @@ func (s *Safe) SafeAdd() (*Safe, error) { affected, _ := result.RowsAffected() id, _ := result.LastInsertId() log.Printf("SafeAdd insert returned result id '%d' affecting %d row(s).\n", id, affected) + s.SafeId = int(id) log.Printf("safe: %v\n", s) } } else {