Skip to content

Commit

Permalink
updates to order lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
KenWilliamson committed Aug 14, 2020
1 parent 6ef5b6e commit d24e664
Show file tree
Hide file tree
Showing 8 changed files with 1,023 additions and 909 deletions.
1,830 changes: 922 additions & 908 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.20
github.com/Ulbora/six910-database-interface v1.0.22
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 @@ -30,6 +30,10 @@ github.com/Ulbora/six910-database-interface v1.0.19 h1:gfVmg0TAn065ytdFcVYrY1Zvc
github.com/Ulbora/six910-database-interface v1.0.19/go.mod h1:OGqZQ5ETgqxsHB636qmivSR36NzQxhV4T+ATsIUJSLM=
github.com/Ulbora/six910-database-interface v1.0.20 h1:c4niG5rNG4uXB2dOUsOUYPyLoQfY8dIHpnLhlV4f/nc=
github.com/Ulbora/six910-database-interface v1.0.20/go.mod h1:OGqZQ5ETgqxsHB636qmivSR36NzQxhV4T+ATsIUJSLM=
github.com/Ulbora/six910-database-interface v1.0.21 h1:H8OPfohHVbk/D0mCB+/ExdsK55h4VTlJTDqzo9Mo7Ic=
github.com/Ulbora/six910-database-interface v1.0.21/go.mod h1:OGqZQ5ETgqxsHB636qmivSR36NzQxhV4T+ATsIUJSLM=
github.com/Ulbora/six910-database-interface v1.0.22 h1:69dlWaB9CZt6zuMhCMOpQuphaEMlngq52dYsg16zJ/8=
github.com/Ulbora/six910-database-interface v1.0.22/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
10 changes: 10 additions & 0 deletions mockDbMeths.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,16 @@ func (d *MockSix910Mysql) GetOrderList(cid int64, storeID int64) *[]mdb.Order {
return d.MockOrderList
}

//GetStoreOrderList GetStoreOrderList
func (d *MockSix910Mysql) GetStoreOrderList(storeID int64) *[]mdb.Order {
return d.MockOrderList
}

//GetStoreOrderListByStatus GetStoreOrderListByStatus
func (d *MockSix910Mysql) GetStoreOrderListByStatus(status string, storeID int64) *[]mdb.Order {
return d.MockOrderList
}

//DeleteOrder DeleteOrder
func (d *MockSix910Mysql) DeleteOrder(id int64) bool {
return d.MockDeleteOrderSuccess
Expand Down
12 changes: 12 additions & 0 deletions mockDb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,18 @@ func TestMockSix910Mysql_Mocks(t *testing.T) {
t.Fail()
}

sdb.MockOrderList = &odrlst
fodrlst2 := si.GetStoreOrderList(6)
if len(*fodrlst2) != 1 {
t.Fail()
}

sdb.MockOrderList = &odrlst
fodrlst3 := si.GetStoreOrderListByStatus("test", 6)
if len(*fodrlst3) != 1 {
t.Fail()
}

sdb.MockDeleteOrderSuccess = true
dlodr := si.DeleteOrder(4)
if !dlodr {
Expand Down
40 changes: 40 additions & 0 deletions order.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,46 @@ func (d *Six910Mysql) GetOrderList(cid int64, storeID int64) *[]mdb.Order {
return &rtn
}

//GetStoreOrderList GetStoreOrderList
func (d *Six910Mysql) GetStoreOrderList(storeID int64) *[]mdb.Order {
if !d.testConnection() {
d.DB.Connect()
}
var rtn = []mdb.Order{}
var a []interface{}
a = append(a, storeID)
rows := d.DB.GetList(getOrderForStore, a...)
if rows != nil && len(rows.Rows) != 0 {
foundRows := rows.Rows
for r := range foundRows {
foundRow := foundRows[r]
rowContent := d.parseOrderRow(&foundRow)
rtn = append(rtn, *rowContent)
}
}
return &rtn
}

//GetStoreOrderListByStatus GetStoreOrderListByStatus
func (d *Six910Mysql) GetStoreOrderListByStatus(status string, storeID int64) *[]mdb.Order {
if !d.testConnection() {
d.DB.Connect()
}
var rtn = []mdb.Order{}
var a []interface{}
a = append(a, storeID, status)
rows := d.DB.GetList(getOrderForStoreByStatus, a...)
if rows != nil && len(rows.Rows) != 0 {
foundRows := rows.Rows
for r := range foundRows {
foundRow := foundRows[r]
rowContent := d.parseOrderRow(&foundRow)
rtn = append(rtn, *rowContent)
}
}
return &rtn
}

//DeleteOrder DeleteOrder
func (d *Six910Mysql) DeleteOrder(id int64) bool {
if !d.testConnection() {
Expand Down
21 changes: 21 additions & 0 deletions order_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,27 @@ func TestSix910Mysql_Order(t *testing.T) {
t.Fail()
}

dbi.Close()
fodrlist2 := si.GetStoreOrderList(sid)
fmt.Println("fodrlist2: ", fodrlist2)
if len(*fodrlist2) != 1 {
t.Fail()
}

dbi.Close()
fodrlist3 := si.GetStoreOrderListByStatus("Processing2", sid)
fmt.Println("fodrlist3: ", fodrlist3)
if len(*fodrlist3) != 1 {
t.Fail()
}

dbi.Close()
fodrlist4 := si.GetStoreOrderListByStatus("new", sid)
fmt.Println("fodrlist4: ", fodrlist4)
if len(*fodrlist4) != 0 {
t.Fail()
}

dbi.Close()
dlodr := si.DeleteOrder(oid)
if !dlodr {
Expand Down
13 changes: 13 additions & 0 deletions queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,19 @@ const (
" FROM orders " +
" WHERE customer_id = ? and store_id = ? "

getOrderForStore = "SELECT id, order_date, updated, status, subtotal, shipping_handling, " +
" insurance, taxes, total, customer_id, billing_address_id, shipping_address_id, customer_name, " +
" billing_address, shipping_address, store_id, order_number, order_type, pickup, username" +
" FROM orders " +
" WHERE store_id = ? " +
" ORDER by status"

getOrderForStoreByStatus = "SELECT id, order_date, updated, status, subtotal, shipping_handling, " +
" insurance, taxes, total, customer_id, billing_address_id, shipping_address_id, customer_name, " +
" billing_address, shipping_address, store_id, order_number, order_type, pickup, username" +
" FROM orders " +
" WHERE store_id = ? and status = ? "

deleteOrder = "DELETE FROM orders WHERE id = ? "

insertOrderItem = "INSERT INTO order_item (order_id, product_id, product_name, product_short_desc, " +
Expand Down

0 comments on commit d24e664

Please sign in to comment.