Commit 635b0e33 by huangchengyi

拦截分类参数不得为空

parent 0809dfcf
Showing with 6 additions and 0 deletions
package query
import (
"errors"
"github.com/gin-gonic/gin"
"gopkg.in/olivere/elastic.v5"
"search_server/pkg/common"
......@@ -30,6 +31,11 @@ func GetOptimumAttrQuery(ctx *gin.Context,REQUEST_ATTR *map[string][]string,type
if class_id2 != "" {
query.Must(elastic.NewTermQuery("class_id2",class_id2))
}
if class_id1 == "" && class_id2 == "" {
return "",errors.New("分类参数不得为空")
}
if ctx.Request.FormValue("avail_rank") == "1" { //只显示有货
query.Must(elastic.NewRangeQuery("stock").Gt(0))
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment