|
|
@@ -111,6 +111,7 @@ type Product struct {
|
|
|
HaveSize bool `orm:"-" json:"have_size"` // bool
|
|
|
SizeName string `orm:"-" json:"size_name"` // varchar(255)
|
|
|
ColorName string `orm:"-" json:"color_name"` // varchar(255)
|
|
|
+ KeyWords string `orm:"column(key_words)" json:"key_words"` // varchar(255)
|
|
|
SinglePurchLimit int64 `orm:"column(single_purch_limit)" json:"-"` // varchar(255)
|
|
|
Pv int64 `orm:"column(pv)" json:"-"` // varchar(255)
|
|
|
OutNums int64 `orm:"column(out_nums)" json:"-"` // varchar(255)
|
|
|
@@ -182,8 +183,8 @@ func GetProductById(id int64, useCache bool) *Product {
|
|
|
return item
|
|
|
}
|
|
|
|
|
|
-func GetProductsByCatId(cId, page, perPage int64, useCache bool) (products []*Product) {
|
|
|
- k := fmt.Sprintf("product_model.GetProductsByCatId(%d).page(%d).perPage(%d)", cId, page, perPage)
|
|
|
+func GetProductsByCatId(cId, page, perPage int64, words string, useCache bool) (products []*Product) {
|
|
|
+ k := fmt.Sprintf("product_model.GetProductsByCatId(%d).page(%d).perPage(%d).words(%d)", cId, page, perPage, words)
|
|
|
if useCache {
|
|
|
if ret, ok := cache.Cache.Get(k).([]*Product); ok {
|
|
|
return ret
|
|
|
@@ -193,8 +194,9 @@ func GetProductsByCatId(cId, page, perPage int64, useCache bool) (products []*Pr
|
|
|
qs := o.QueryTable(new(Product)).Filter("status", 1).Filter("show_flag", true).Filter("ptype", TYPE_DIRECT_SALE)
|
|
|
if cId != 0 {
|
|
|
qs = qs.Filter("category_id", cId)
|
|
|
- } else {
|
|
|
- qs = qs.Exclude("category_id", 3) //3为审核类别,暂写死
|
|
|
+ }
|
|
|
+ if len(words) > 0 {
|
|
|
+ qs = qs.Filter("key_words__icontains", words)
|
|
|
}
|
|
|
_, err := qs.
|
|
|
OrderBy("-recommend", "-created_at").
|
|
|
@@ -212,7 +214,7 @@ func GetProductsByCatId(cId, page, perPage int64, useCache bool) (products []*Pr
|
|
|
return products
|
|
|
}
|
|
|
|
|
|
-func GetProductCountByCatId(cId int64, useCache bool) int64 {
|
|
|
+func GetProductCountByCatId(cId int64, words string, useCache bool) int64 {
|
|
|
k := fmt.Sprintf("product_model.GetProductCountByCatId(%d)", cId)
|
|
|
if useCache {
|
|
|
if ret, ok := cache.Cache.Get(k).(int64); ok {
|
|
|
@@ -224,8 +226,9 @@ func GetProductCountByCatId(cId int64, useCache bool) int64 {
|
|
|
qs := o.QueryTable(item)
|
|
|
if cId != 0 {
|
|
|
qs = qs.Filter("category_id", cId)
|
|
|
- } else {
|
|
|
- qs = qs.Exclude("category_id", 3) //3为审核类别,暂写死
|
|
|
+ }
|
|
|
+ if len(words) > 0 {
|
|
|
+ qs = qs.Filter("key_words__icontains", words)
|
|
|
}
|
|
|
count, _ := qs.Filter("status", 1).Filter("show_flag", true).Filter("ptype", TYPE_DIRECT_SALE).Count()
|
|
|
|