From e00cefb8e4fb9faafa8f3216dc609480629e2fa1 Mon Sep 17 00:00:00 2001 From: Hazem Krimi Date: Mon, 2 Jun 2025 17:55:51 +0100 Subject: [PATCH] chore: update client schema --- internal/api/api.go | 4 ++-- internal/models/client.go | 38 +++++++++++++++++++++++++------------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/internal/api/api.go b/internal/api/api.go index 0a2e3c4..14b6e77 100644 --- a/internal/api/api.go +++ b/internal/api/api.go @@ -2,8 +2,8 @@ package api import ( "github.com/hazemKrimi/crimson-vault/internal/models" - "github.com/labstack/echo/v4/middleware" "github.com/labstack/echo/v4" + "github.com/labstack/echo/v4/middleware" ) type API struct { @@ -18,8 +18,8 @@ func (api *API) Initialize() { db.Connect() db.MigrateClients() - api.db = db api.instance = ech + api.db = db api.ClientRoutes() api.instance.Use(middleware.CORSWithConfig(middleware.CORSConfig{ diff --git a/internal/models/client.go b/internal/models/client.go index b6d5381..57f5beb 100644 --- a/internal/models/client.go +++ b/internal/models/client.go @@ -7,25 +7,37 @@ import ( ) type Client struct { - ID uint32 `json:"id"` - CreatedAt time.Time `json:"createAt"` - UpdatedAt time.Time `json:"updatedAt"` - DeletedAt gorm.DeletedAt `json:"deletedAt" gorm:"index"` - Name string `json:"name"` - Country string `json:"country"` - Phone string `json:"phone"` + ID uint32 `json:"id"` + CreatedAt time.Time `json:"createAt"` + UpdatedAt time.Time `json:"updatedAt"` + DeletedAt gorm.DeletedAt `json:"deletedAt" gorm:"index"` + Name string `json:"name"` + FiscalCode string `json:"fiscalCode"` + Address string `json:"address"` + Zip string `json:"zip"` + Country string `json:"country"` + Phone string `json:"phone"` + Email string `json:"email"` } type CreateClientBody struct { - Name string `json:"name"` - Country string `json:"country"` - Phone string `json:"phone"` + Name string `json:"name"` + FiscalCode string `json:"fiscalCode"` + Address string `json:"address"` + Zip string `json:"zip"` + Country string `json:"country"` + Phone string `json:"phone"` + Email string `json:"email"` } type UpdateClientBody struct { - Name string `json:"name"` - Country string `json:"country"` - Phone string `json:"phone"` + Name string `json:"name"` + FiscalCode string `json:"fiscalCode"` + Address string `json:"address"` + Zip string `json:"zip"` + Country string `json:"country"` + Phone string `json:"phone"` + Email string `json:"email"` } func (db *DB) MigrateClients() {