From 327a32f563394f92313e4a751515d69d90f4e7f5 Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Sun, 12 Oct 2025 23:30:08 +0530 Subject: formatted code --- customer/controller.go | 10 +++++----- customer/customer.go | 25 +++++++++++++------------ customer/hooks.go | 2 +- 3 files changed, 19 insertions(+), 18 deletions(-) (limited to 'customer') diff --git a/customer/controller.go b/customer/controller.go index 83423da..b9b2b25 100644 --- a/customer/controller.go +++ b/customer/controller.go @@ -18,13 +18,13 @@ package customer import ( - e "vidhukant.com/openbills/errors" "github.com/gin-gonic/gin" "net/http" "strconv" + e "vidhukant.com/openbills/errors" ) -func handleGetSingleCustomer (ctx *gin.Context) { +func handleGetSingleCustomer(ctx *gin.Context) { id, err := strconv.ParseUint(ctx.Param("id"), 10, 64) if err != nil { ctx.Error(e.ErrInvalidID) @@ -44,7 +44,7 @@ func handleGetSingleCustomer (ctx *gin.Context) { }) } -func handleGetCustomers (ctx *gin.Context) { +func handleGetCustomers(ctx *gin.Context) { var customers []Customer err := getCustomers(&customers) @@ -59,7 +59,7 @@ func handleGetCustomers (ctx *gin.Context) { }) } -func handleSaveCustomer (ctx *gin.Context) { +func handleSaveCustomer(ctx *gin.Context) { var customer Customer ctx.Bind(&customer) @@ -75,7 +75,7 @@ func handleSaveCustomer (ctx *gin.Context) { }) } -func handleDelCustomer (ctx *gin.Context) { +func handleDelCustomer(ctx *gin.Context) { id, err := strconv.ParseUint(ctx.Param("id"), 10, 64) if err != nil { ctx.Error(e.ErrInvalidID) diff --git a/customer/customer.go b/customer/customer.go index 0d107d7..cf5c3f1 100644 --- a/customer/customer.go +++ b/customer/customer.go @@ -23,6 +23,7 @@ import ( ) var db *gorm.DB + func init() { db = d.DB @@ -31,18 +32,18 @@ func init() { type Customer struct { gorm.Model - FirmName string - Gstin string - ContactName string - Phone string - Email string - Website string - - BillingAddressText string - BillingAddressCity string - BillingAddressState string - BillingAddressPostalCode string - BillingAddressCountry string + FirmName string + Gstin string + ContactName string + Phone string + Email string + Website string + + BillingAddressText string + BillingAddressCity string + BillingAddressState string + BillingAddressPostalCode string + BillingAddressCountry string ShippingAddressText string ShippingAddressCity string diff --git a/customer/hooks.go b/customer/hooks.go index 7f715c3..2160f40 100644 --- a/customer/hooks.go +++ b/customer/hooks.go @@ -34,7 +34,7 @@ func (c *Customer) BeforeSave(tx *gorm.DB) error { } func (c *Customer) BeforeDelete(tx *gorm.DB) error { - // if ID is 0, customer won't be deleted + // if ID is 0, customer won't be deleted if c.ID == 0 { return errors.ErrNoWhereCondition } -- cgit v1.2.3