|
|
|
@ -15,9 +15,9 @@ func init() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type List2Params struct {
|
|
|
|
type List2Params struct {
|
|
|
|
CategoryId int64 `json:"category_id"`
|
|
|
|
CategoryId interface{} `json:"category_id"`
|
|
|
|
Keywords string `json:"keywords"`
|
|
|
|
Keywords string `json:"keywords"`
|
|
|
|
Page int64 `json:"page"`
|
|
|
|
Page int64 `json:"page"`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func List2(rpcConn towgo.JsonRpcConnection) {
|
|
|
|
func List2(rpcConn towgo.JsonRpcConnection) {
|
|
|
|
@ -32,7 +32,9 @@ func List2(rpcConn towgo.JsonRpcConnection) {
|
|
|
|
var gcr good_category_re.GoodCategoryRe
|
|
|
|
var gcr good_category_re.GoodCategoryRe
|
|
|
|
var gcrs []good_category_re.GoodCategoryRe
|
|
|
|
var gcrs []good_category_re.GoodCategoryRe
|
|
|
|
var listGcr basedboperat.List
|
|
|
|
var listGcr basedboperat.List
|
|
|
|
|
|
|
|
listGcr.Limit = 10
|
|
|
|
var listGood basedboperat.List
|
|
|
|
var listGood basedboperat.List
|
|
|
|
|
|
|
|
listGood.Limit = 10
|
|
|
|
if params.CategoryId != 0 {
|
|
|
|
if params.CategoryId != 0 {
|
|
|
|
listGcr.Where = append(listGcr.Where, basedboperat.Condition{
|
|
|
|
listGcr.Where = append(listGcr.Where, basedboperat.Condition{
|
|
|
|
Field: "category_id",
|
|
|
|
Field: "category_id",
|
|
|
|
@ -40,18 +42,37 @@ func List2(rpcConn towgo.JsonRpcConnection) {
|
|
|
|
Value: params.CategoryId,
|
|
|
|
Value: params.CategoryId,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*tempMap := make(map[string][]string)
|
|
|
|
if params.CategoryId != "0" {
|
|
|
|
if params.Keywords != "" {
|
|
|
|
listGcr.Where = append(listGcr.Where, basedboperat.Condition{
|
|
|
|
tempMap["title"] = "%" + params.Keywords + "%"
|
|
|
|
Field: "category_id",
|
|
|
|
listGood.Like = tempMap
|
|
|
|
Operator: "=",
|
|
|
|
append(listGood.Where, basedboperat.Condition{
|
|
|
|
Value: params.CategoryId,
|
|
|
|
Field: "title",
|
|
|
|
|
|
|
|
Operator: "like",
|
|
|
|
|
|
|
|
Value: "%" + params.Keywords + "%",
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}*/
|
|
|
|
}
|
|
|
|
|
|
|
|
if params.Keywords != "" {
|
|
|
|
|
|
|
|
listGood.Like = make(map[string][]interface{})
|
|
|
|
|
|
|
|
listGood.Like["title"] = []interface{}{"%" + params.Keywords + "%"}
|
|
|
|
|
|
|
|
}
|
|
|
|
basedboperat.ListScan(&listGcr, &gcr, &gcrs)
|
|
|
|
basedboperat.ListScan(&listGcr, &gcr, &gcrs)
|
|
|
|
basedboperat.ListScan(&listGood, &good, &goods)
|
|
|
|
//basedboperat.ListScan(&listGood, &good, &goods)
|
|
|
|
|
|
|
|
sql := "select * from " + good.TableName() + " where title like '%" + params.Keywords + "%'"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
err = basedboperat.SqlQueryScan(&goods, sql)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
log.Println(err)
|
|
|
|
|
|
|
|
//rpcConn.WriteError(500, err.Error())
|
|
|
|
|
|
|
|
//return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
sql = "select count(id) as `count` from " + good.TableName()
|
|
|
|
|
|
|
|
var m []map[string]interface{}
|
|
|
|
|
|
|
|
err = basedboperat.SqlQueryScan(&m, sql)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
log.Println(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
count := int64(m[0]["count"].(float64))
|
|
|
|
|
|
|
|
|
|
|
|
mapGcrs := make(map[int64]int64)
|
|
|
|
mapGcrs := make(map[int64]int64)
|
|
|
|
for _, v := range gcrs {
|
|
|
|
for _, v := range gcrs {
|
|
|
|
mapGcrs[v.GoodsId] = v.CategoryId
|
|
|
|
mapGcrs[v.GoodsId] = v.CategoryId
|
|
|
|
@ -60,10 +81,28 @@ func List2(rpcConn towgo.JsonRpcConnection) {
|
|
|
|
for _, v := range goods {
|
|
|
|
for _, v := range goods {
|
|
|
|
if mapGcrs[v.ID] != 0 {
|
|
|
|
if mapGcrs[v.ID] != 0 {
|
|
|
|
resultGoods = append(resultGoods, v)
|
|
|
|
resultGoods = append(resultGoods, v)
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type data struct {
|
|
|
|
rpcConn.WriteResult(resultGoods)
|
|
|
|
ResultGoods []Goods `json:"resultGoods"`
|
|
|
|
|
|
|
|
CurrentPage int64 `json:"current_Page"`
|
|
|
|
|
|
|
|
LastPage int64 `json:"last_page"`
|
|
|
|
|
|
|
|
PerPage int64 `json:"per_page"`
|
|
|
|
|
|
|
|
Total int64 `json:"total"`
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var lastPage int64
|
|
|
|
|
|
|
|
if count%10 == 0 {
|
|
|
|
|
|
|
|
lastPage = count / 10
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
lastPage = count/10 + 1
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
d := data{
|
|
|
|
|
|
|
|
ResultGoods: resultGoods,
|
|
|
|
|
|
|
|
CurrentPage: params.Page,
|
|
|
|
|
|
|
|
LastPage: lastPage,
|
|
|
|
|
|
|
|
PerPage: 10,
|
|
|
|
|
|
|
|
Total: count,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
rpcConn.WriteResult(d)
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|