Skip to content

Commit

Permalink
adding extended search functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
KenWilliamson committed Aug 5, 2022
1 parent 23e9a89 commit 29c5d01
Show file tree
Hide file tree
Showing 14 changed files with 2,101 additions and 1,642 deletions.
2 changes: 1 addition & 1 deletion contentsrv/testFiles/index.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name":"index","title":"the best book ever","subject":"","author":"ken","createDate":"2022-08-02T17:28:45.780602736-04:00","modifiedDate":"0001-01-01T00:00:00Z","hits":0,"metaAuthorName":"ken","metaDesc":"shopping cart index","metaKeyWords":"","metaRobotKeyWords":"","text":"c29tZSBib29rIHRleHQ=","TextHTML":"","archived":false,"visible":true,"UseModifiedDate":false,"blogPost":false}
{"name":"index","title":"the best book ever","subject":"","author":"ken","createDate":"2022-08-04T15:44:41.829288863-04:00","modifiedDate":"0001-01-01T00:00:00Z","hits":0,"metaAuthorName":"ken","metaDesc":"shopping cart index","metaKeyWords":"","metaRobotKeyWords":"","text":"c29tZSBib29rIHRleHQ=","TextHTML":"","archived":false,"visible":true,"UseModifiedDate":false,"blogPost":false}
2 changes: 1 addition & 1 deletion contentsrv/testFiles/product.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name":"product","title":"the best book ever","subject":"","author":"ken","createDate":"2022-08-02T17:28:45.794707081-04:00","modifiedDate":"0001-01-01T00:00:00Z","hits":0,"metaAuthorName":"ken","metaDesc":"shopping cart index","metaKeyWords":"","metaRobotKeyWords":"","text":"c29tZSBib29rIHRleHQ=","TextHTML":"","archived":false,"visible":true,"UseModifiedDate":false,"blogPost":false}
{"name":"product","title":"the best book ever","subject":"","author":"ken","createDate":"2022-08-04T15:44:41.847409097-04:00","modifiedDate":"0001-01-01T00:00:00Z","hits":0,"metaAuthorName":"ken","metaDesc":"shopping cart index","metaKeyWords":"","metaRobotKeyWords":"","text":"c29tZSBib29rIHRleHQ=","TextHTML":"","archived":false,"visible":true,"UseModifiedDate":false,"blogPost":false}
1 change: 1 addition & 0 deletions contentsrv/testFiles/productList.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"productList","title":"the best book ever","subject":"","author":"ken","createDate":"2022-08-04T15:44:41.833786584-04:00","modifiedDate":"0001-01-01T00:00:00Z","hits":0,"metaAuthorName":"ken","metaDesc":"shopping cart index","metaKeyWords":"","metaRobotKeyWords":"","text":"c29tZSBib29rIHRleHQ=","TextHTML":"","archived":false,"visible":true,"UseModifiedDate":false,"blogPost":false}
2 changes: 1 addition & 1 deletion countrysrv/coverage.out
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mode: set
github.com/Ulbora/Six910-ui/countrysrv/service.go:47.56,49.2 1 1
github.com/Ulbora/Six910-ui/countrysrv/countryService.go:30.71,33.16 3 1
github.com/Ulbora/Six910-ui/countrysrv/countryService.go:36.2,36.13 1 1
github.com/Ulbora/Six910-ui/countrysrv/countryService.go:33.16,35.3 1 1
github.com/Ulbora/Six910-ui/countrysrv/service.go:47.56,49.2 1 1
2,845 changes: 1,427 additions & 1,418 deletions handlers/coverage.out

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions handlers/customerIndexHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ type CustomerPage struct {
CategoryID string
CategoryName string
SearchName string
Color string
Size string
Gender string
ManufacturerList *[]string
Manufacturer string
PageBody *csssrv.PageCSS
Expand Down
51 changes: 37 additions & 14 deletions handlers/customerProductHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package handlers

import (
"container/list"
"fmt"
"net/http"
"strconv"
"strings"
Expand Down Expand Up @@ -451,23 +452,30 @@ func (h *Six910Handler) ProductSearchByDescAttributes(w http.ResponseWriter, r *
h.Log.Debug("session suc", suc)
if suc {
//var pagebdy PageBody
var color string
var size string
var gender string

csrplsearch := r.FormValue("search")
color = r.FormValue("color")
size = r.FormValue("size")
gender = r.FormValue("gender")

var acsplstart int64
var acsplend int64

var color string
var size string
var gender string
fmt.Println("Search: ", csrplsearch)
fmt.Println("Gender: ", gender)

if csrplsearch == "" {
acsplvars := mux.Vars(r)
csrplsearch = acsplvars["search"]
acsplststr := acsplvars["start"]
acsplendstr := acsplvars["end"]

color = acsplvars["color"]
size = acsplvars["size"]
gender = acsplvars["gender"]
// color = acsplvars["color"]
// size = acsplvars["size"]
// gender = acsplvars["gender"]

//add addition params for gender color and size
//and do productSearch to temp product list and remove products that
Expand All @@ -494,15 +502,9 @@ func (h *Six910Handler) ProductSearchByDescAttributes(w http.ResponseWriter, r *

tempsppl := h.API.ProductSearch(&psratt, hd)

if color != "" || size != "" || gender != "" {
// var filProdList []sdbi.Product
sppl = h.filterProduct(color, size, gender, tempsppl)

//-----------------------------
// add code to eliminate unneeded products
//----------------------------
} else {
sppl = tempsppl
}
h.Log.Debug("sppl: ", sppl)

// may need to modify this search too

Expand All @@ -529,6 +531,9 @@ func (h *Six910Handler) ProductSearchByDescAttributes(w http.ResponseWriter, r *
acsplpage.Content = &ct
}
acsplpage.SearchName = csrplsearch
acsplpage.Color = color
acsplpage.Size = size
acsplpage.Gender = gender
acsplpage.Manufacturer = ""

//csplpage.MenuList = h.MenuService.GetMenuList()
Expand Down Expand Up @@ -690,3 +695,21 @@ func (h *Six910Handler) getProductCatList(l *list.List, cid int64, hd *api.Heade
return h.getProductCatList(l, pc.ParentCategoryID, hd)

}

func (h *Six910Handler) filterProduct(color string, size string, gender string, plst *[]sdbi.Product) *[]sdbi.Product {
var rtn []sdbi.Product

for _, p := range *plst {
if color != "" && strings.ToLower(p.Color) != strings.ToLower(color) {
continue
}
if size != "" && strings.ToLower(p.Size) != strings.ToLower(size) {
continue
}
if gender != "" && strings.ToLower(p.Gender) != strings.ToLower(gender) {
continue
}
rtn = append(rtn, p)
}
return &rtn
}
Loading

0 comments on commit 29c5d01

Please sign in to comment.