fix: es sort

master
howell 3 years ago
parent 474c18408a
commit 9975d78ed0

@ -22,6 +22,7 @@ import (
"github.com/golangkit/formatime"
"github.com/shopspring/decimal"
gorm2 "gorm.io/gorm"
"gorm.io/gorm/clause"
)
type queryOrderGoodsListParam struct {
@ -102,7 +103,8 @@ func QueryGoodsListByComprehension(c *gin.Context) {
func findByKeyWord(q *gorm2.DB, str string, data *[]goods.Information, page uint) {
if str != "" {
gl, _, _ := search_ali.SearchByAliES(str, 20, int(page))
q.Where("a.id in (?)", gl).Find(&data)
q.Clauses(clause.OrderBy{
Expression: clause.Expr{SQL: "FIELD(id,?)", Vars: []interface{}{gl}, WithoutParentheses: true}}).Where("a.id in (?)", gl).Find(&data)
} else {
q.Limit(20).Offset(int(page * 20)).Find(&data)
}

Loading…
Cancel
Save