diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/database/database.go | 14 | ||||
-rw-r--r-- | server/database/items.go | 30 | ||||
-rw-r--r-- | server/filled.db | bin | 57344 -> 0 bytes | |||
-rw-r--r-- | server/router/items.go | 14 |
4 files changed, 28 insertions, 30 deletions
diff --git a/server/database/database.go b/server/database/database.go index c2c0dfe..f8d9092 100644 --- a/server/database/database.go +++ b/server/database/database.go @@ -20,13 +20,13 @@ func InitDB() { init_items, _ := myDatabase.Prepare( `CREATE TABLE IF NOT EXISTS Items (id INTEGER PRIMARY KEY AUTOINCREMENT, - Model TEXT NOT NULL, - Desc TEXT, - Price REAL, - Hsn BLOB, - Gst REAL, - Category TEXT, - Brand TEXT)`, + Model TEXT NOT NULL, + Desc TEXT, + UnitPrice REAL, + HSN BLOB, + TotalGST REAL, + Category TEXT, + Brand TEXT)`, ) init_items.Exec() diff --git a/server/database/items.go b/server/database/items.go index 325b7c1..059f5e6 100644 --- a/server/database/items.go +++ b/server/database/items.go @@ -14,30 +14,30 @@ import ( ) type Item struct { - Model string - Desc string `json:"Description"` - Price float64 - HSN int - GST float64 - Cat string `json:"Category"` - Brand string + Model string + Description string + UnitPrice float64 + HSN int + TotalGST float64 + Category string + Brand string } func GetAllItems() []Item { var allItems []Item rows, _ := myDatabase.Query( - `SELECT Model, Desc, Price, Hsn, Gst, Category, Brand FROM Items`, + `SELECT Model, Desc, UnitPrice, HSN, TotalGST, Category, Brand FROM Items`, ) var ( model, desc, cat, brand string - price, GST float64 + unitPrice, GST float64 HSN int ) for rows.Next() { - rows.Scan(&model, &desc, &price, &HSN, &GST, &cat, &brand) - allItems = append(allItems, Item{model, desc, price, HSN, GST, cat, brand}) + rows.Scan(&model, &desc, &unitPrice, &HSN, &GST, &cat, &brand) + allItems = append(allItems, Item{model, desc, unitPrice, HSN, GST, cat, brand}) } return allItems @@ -48,7 +48,7 @@ func RegisterItem(item Item) bool { register_item, _ := myDatabase.Prepare( `INSERT INTO Items - (Model, Desc, Price, Hsn, Gst, Category, Brand) + (Model, Desc, UnitPrice, HSN, TotalGST, Category, Brand) VALUES (?, ?, ?, ?, ?, ?, ?)`, ) @@ -64,10 +64,8 @@ func RegisterItem(item Item) bool { } register_item.Exec( - item.Model, item.Desc, - item.Price, item.HSN, - item.GST, item.Cat, - item.Brand, + item.Model, item.Description, item.UnitPrice, item.HSN, + item.TotalGST, item.Category, item.Brand, ) return true diff --git a/server/filled.db b/server/filled.db Binary files differdeleted file mode 100644 index d9258ed..0000000 --- a/server/filled.db +++ /dev/null diff --git a/server/router/items.go b/server/router/items.go index c71fac6..684d1d8 100644 --- a/server/router/items.go +++ b/server/router/items.go @@ -31,13 +31,13 @@ func registerItem(ctx *gin.Context) { brand := "brand coming soon" item := db.Item { - Model: ctx.Query("model"), - Desc: ctx.Query("desc"), - Price: price, - HSN: hsn, - GST: gst, - Cat: cat, - Brand: brand, + Model: ctx.Query("model"), + Description: ctx.Query("desc"), + UnitPrice: price, + HSN: hsn, + TotalGST: gst, + Category: cat, + Brand: brand, } db.RegisterItem(item) |