You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
package goods
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"recook/internal/back"
|
|
|
|
"recook/internal/dbc"
|
|
|
|
"recook/internal/model/goods"
|
|
|
|
"recook/tools"
|
|
|
|
)
|
|
|
|
|
|
|
|
type searchGoodsListParam struct {
|
|
|
|
Keyword string `json:"keyword"`
|
|
|
|
Page uint `json:"page"`
|
|
|
|
Order string `json:"order"`
|
|
|
|
UserID uint `json:"user_id"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func SearchGoodsByKeyword(c *gin.Context) {
|
|
|
|
var p searchGoodsListParam
|
|
|
|
if err := tools.ParseParams(&p, c); err != nil {
|
|
|
|
back.Fail(c, err.Error())
|
|
|
|
return
|
|
|
|
}
|
|
|
|
//p.Order="desc"
|
|
|
|
//p.Keyword="多功能"
|
|
|
|
//p.Page=0
|
|
|
|
var goodsList []goods.Information
|
|
|
|
tx := dbc.DB.Limit(20).Order("sales_volume " + p.Order).Offset(p.Page * 20).Where("publish_status = 1")
|
|
|
|
//if len([]rune(p.Keyword)) > 1 {
|
|
|
|
//tx.Find(&goodsList, "MATCH (goods_name) AGAINST (?)", p.Keyword)
|
|
|
|
//} else {
|
|
|
|
tx.Find(&goodsList, ` goods_name like "%`+p.Keyword+`%"`)
|
|
|
|
//}
|
|
|
|
|
|
|
|
back.Suc(c, "", GetGoodsRespByInfoList(goodsList, p.UserID, false))
|
|
|
|
}
|