Skip to content

Commit

Permalink
updates to products
Browse files Browse the repository at this point in the history
  • Loading branch information
KenWilliamson committed Aug 3, 2020
1 parent 08f1a2b commit ec2aacc
Show file tree
Hide file tree
Showing 8 changed files with 854 additions and 795 deletions.
1,574 changes: 789 additions & 785 deletions coverage.out

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ require (
github.com/Ulbora/Level_Logger v1.0.2
github.com/Ulbora/dbinterface v1.0.5
github.com/Ulbora/dbinterface_mysql v1.0.7
github.com/Ulbora/six910-database-interface v1.0.16
github.com/Ulbora/six910-database-interface v1.0.19
github.com/go-sql-driver/mysql v1.5.0 // indirect
)
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ github.com/Ulbora/six910-database-interface v1.0.15 h1:u6ta1KHz02lVSF9oGGU76/Blw
github.com/Ulbora/six910-database-interface v1.0.15/go.mod h1:OGqZQ5ETgqxsHB636qmivSR36NzQxhV4T+ATsIUJSLM=
github.com/Ulbora/six910-database-interface v1.0.16 h1:ufq46Ws2CDKrhggSO+kBxjf+eSmw8qPBN5l895SsHxc=
github.com/Ulbora/six910-database-interface v1.0.16/go.mod h1:OGqZQ5ETgqxsHB636qmivSR36NzQxhV4T+ATsIUJSLM=
github.com/Ulbora/six910-database-interface v1.0.18 h1:1/FUHbY14RJ8lJtSeDXTAu6oke62zEwClq5+UoWuo54=
github.com/Ulbora/six910-database-interface v1.0.18/go.mod h1:OGqZQ5ETgqxsHB636qmivSR36NzQxhV4T+ATsIUJSLM=
github.com/Ulbora/six910-database-interface v1.0.19 h1:gfVmg0TAn065ytdFcVYrY1Zvct4L/xiQClVnTSmGpFw=
github.com/Ulbora/six910-database-interface v1.0.19/go.mod h1:OGqZQ5ETgqxsHB636qmivSR36NzQxhV4T+ATsIUJSLM=
github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA=
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
Expand Down
5 changes: 5 additions & 0 deletions mockDbMeths.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,11 @@ func (d *MockSix910Mysql) GetProductByID(id int64) *mdb.Product {
return d.MockProduct
}

//GetProductBySku GetProductBySku
func (d *MockSix910Mysql) GetProductBySku(sku string, distributorID int64, storeID int64) *mdb.Product {
return d.MockProduct
}

//GetProductsByName GetProductsByName
func (d *MockSix910Mysql) GetProductsByName(name string, storeID int64, start int64, end int64) *[]mdb.Product {
return d.MockProductList
Expand Down
5 changes: 5 additions & 0 deletions mockDb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,11 @@ func TestMockSix910Mysql_Mocks(t *testing.T) {
t.Fail()
}

fprod2 := si.GetProductBySku("3445", 4, 3)
if fprod2.Color != prod.Color {
t.Fail()
}

var prodlst []sdbi.Product
prodlst = append(prodlst, prod)
sdb.MockProductList = &prodlst
Expand Down
17 changes: 15 additions & 2 deletions product.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (d *Six910Mysql) AddProduct(p *mdb.Product) (bool, int64) {
}
var a []interface{}
a = append(a, p.Sku, p.Gtin, p.Name, p.ShortDesc, p.Desc, p.Cost, p.Msrp, p.Map, p.Price, p.SalePrice,
p.Currency, p.Manufacturer, p.Stock, p.StockAlert, p.Weight, p.Width, p.Height, p.Depth,
p.Currency, p.ManufacturerID, p.Manufacturer, p.Stock, p.StockAlert, p.Weight, p.Width, p.Height, p.Depth,
p.ShippingMarkup, p.Visible, p.Searchable, p.MultiBox, p.ShipSeperately, p.FreeShipping,
time.Now(), p.DistributorID, p.Promoted, p.Dropship, p.Size, p.Color, p.ParentProductID,
p.StoreID, p.Thumbnail, p.Image1, p.Image2, p.Image3, p.Image4, p.SpecialProcessing,
Expand All @@ -54,7 +54,7 @@ func (d *Six910Mysql) UpdateProduct(p *mdb.Product) bool {
}
var a []interface{}
a = append(a, p.Sku, p.Gtin, p.Name, p.ShortDesc, p.Desc, p.Cost, p.Msrp, p.Map, p.Price, p.SalePrice,
p.Currency, p.Manufacturer, p.Stock, p.StockAlert, p.Weight, p.Width, p.Height, p.Depth,
p.Currency, p.ManufacturerID, p.Manufacturer, p.Stock, p.StockAlert, p.Weight, p.Width, p.Height, p.Depth,
p.ShippingMarkup, p.Visible, p.Searchable, p.MultiBox, p.ShipSeperately, p.FreeShipping,
time.Now(), p.DistributorID, p.Promoted, p.Dropship, p.Size, p.Color, p.ParentProductID,
p.Thumbnail, p.Image1, p.Image2, p.Image3, p.Image4, p.SpecialProcessing,
Expand All @@ -75,6 +75,18 @@ func (d *Six910Mysql) GetProductByID(id int64) *mdb.Product {
return rtn
}

//GetProductBySku GetProductBySku
func (d *Six910Mysql) GetProductBySku(sku string, distributorID int64, storeID int64) *mdb.Product {
if !d.testConnection() {
d.DB.Connect()
}
var a []interface{}
a = append(a, sku, distributorID, storeID)
row := d.DB.Get(getProductBySku, a...)
rtn := d.parseProductRow(&row.Row)
return rtn
}

//GetProductsByName GetProductsByName
func (d *Six910Mysql) GetProductsByName(name string, storeID int64, start int64, end int64) *[]mdb.Product {
if !d.testConnection() {
Expand Down Expand Up @@ -258,6 +270,7 @@ func (d *Six910Mysql) parseProductRow(foundRow *[]string) *mdb.Product {
rtn.Image3 = (*foundRow)[37]
rtn.Image4 = (*foundRow)[39]
rtn.SpecialProcessingType = (*foundRow)[40]
rtn.ManufacturerID = (*foundRow)[41]

}
}
Expand Down
20 changes: 20 additions & 0 deletions product_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ func TestSix910Mysql_AddProduct(t *testing.T) {
prod.Image3 = "image32"
prod.Image4 = "image42"
prod.Manufacturer = "some mfg2"
prod.ManufacturerID = "mfg2-11111"
prod.Map = 150.92
prod.Msrp = 185.92
prod.MultiBox = true
Expand Down Expand Up @@ -196,6 +197,25 @@ func TestSix910Mysql_AddProduct(t *testing.T) {
t.Fail()
}

dbi.Close()
fprod2 := si.GetProductBySku("1234567892", did, sid)
fmt.Println("fprod", fprod2)
if fprod2.ID != pid || fprod2.ManufacturerID != prod.ManufacturerID {
t.Fail()
}
if fprod2.DistributorID != did {
t.Fail()
}
if fprod2.StoreID != sid {
t.Fail()
}
if fprod2.Map != prod.Map {
t.Fail()
}
if fprod2.MultiBox != prod.MultiBox {
t.Fail()
}

dbi.Close()
fprodn := si.GetProductsByName("well2", sid, 0, 100)
fmt.Println("fprodn", fprodn)
Expand Down
22 changes: 15 additions & 7 deletions queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,15 @@ const (
deleteCategory = "DELETE FROM category WHERE id = ? or parent_category_id = ?"

insertProduct = "INSERT into product(sku, gtin, name, short_description, description, " +
" cost, msrp, map, price, sale_price, currency, manufacturer, stock, stock_alert, weight, " +
" cost, msrp, map, price, sale_price, currency, manufacturer_id, manufacturer, stock, stock_alert, weight, " +
" width, height, depth, shipping_markup, visible, searchable, multibox, " +
" ship_separate, free_shipping, date_entered, distributor_id, promoted, dropship, " +
" size, color, parient_product_id, store_id, thumbnail, image1, image2, image3, " +
" image4, special_processing, special_processing_type) " +
" values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
" values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"

updateProduct = "UPDATE product SET sku = ?, gtin = ?, name = ?, short_description = ?, description = ?, " +
" cost = ?, msrp = ?, map = ?, price = ?, sale_price = ?, currency = ?, manufacturer = ?, stock = ?, " +
" cost = ?, msrp = ?, map = ?, price = ?, sale_price = ?, currency = ?, manufacturer_id = ?, manufacturer = ?, stock = ?, " +
" stock_alert = ?, weight = ?, " +
" width = ?, height = ?, depth = ?, shipping_markup = ?, visible = ?, searchable = ?, multibox = ?, " +
" ship_separate = ?, free_shipping = ?, date_updated = ?, distributor_id = ?, promoted = ?, dropship = ?, " +
Expand All @@ -191,16 +191,24 @@ const (
" width, height, depth, shipping_markup, visible, searchable, multibox, " +
" ship_separate, free_shipping, date_entered, date_updated, distributor_id, promoted, dropship, " +
" size, color, parient_product_id, store_id, thumbnail, image1, image2, image3, " +
" image4, special_processing, special_processing_type " +
" image4, special_processing, special_processing_type, manufacturer_id " +
" FROM product " +
" WHERE id = ? "
getProductBySku = "SELECT id, sku, gtin, name, short_description, description, " +
" cost, msrp, map, price, sale_price, currency, manufacturer, stock, stock_alert, weight, " +
" width, height, depth, shipping_markup, visible, searchable, multibox, " +
" ship_separate, free_shipping, date_entered, date_updated, distributor_id, promoted, dropship, " +
" size, color, parient_product_id, store_id, thumbnail, image1, image2, image3, " +
" image4, special_processing, special_processing_type, manufacturer_id " +
" FROM product " +
" WHERE sku = ? and distributor_id = ? and store_id = ? "

getProductByName = "SELECT id, sku, gtin, name, short_description, description, " +
" cost, msrp, map, price, sale_price, currency, manufacturer, stock, stock_alert, weight, " +
" width, height, depth, shipping_markup, visible, searchable, multibox, " +
" ship_separate, free_shipping, date_entered, date_updated, distributor_id, promoted, dropship, " +
" size, color, parient_product_id, store_id, thumbnail, image1, image2, image3, " +
" image4, special_processing, special_processing_type " +
" image4, special_processing, special_processing_type, manufacturer_id " +
" FROM product " +
" WHERE name like ? and store_id = ? LIMIT ?, ? "

Expand All @@ -209,7 +217,7 @@ const (
" p.width, p.height, p.depth, p.shipping_markup, p.visible, p.searchable, p.multibox, " +
" p.ship_separate, p.free_shipping, p.date_entered, p.date_updated, p.distributor_id, p.promoted, p.dropship, " +
" p.size, p.color, p.parient_product_id, p.store_id, p.thumbnail, p.image1, p.image2, p.image3, " +
" p.image4, p.special_processing, p.special_processing_type " +
" p.image4, p.special_processing, p.special_processing_type, p.manufacturer_id " +
" FROM product p " +
" inner join product_category pc " +
" on p.id = pc.product_id " +
Expand All @@ -222,7 +230,7 @@ const (
" width, height, depth, shipping_markup, visible, searchable, multibox, " +
" ship_separate, free_shipping, date_entered, date_updated, distributor_id, promoted, dropship, " +
" size, color, parient_product_id, store_id, thumbnail, image1, image2, image3, " +
" image4, special_processing, special_processing_type " +
" image4, special_processing, special_processing_type, manufacturer_id " +
" FROM product " +
" WHERE store_id = ? LIMIT ?, ? "

Expand Down

0 comments on commit ec2aacc

Please sign in to comment.