Commit 1d38c6f8 authored by shajiaiming's avatar shajiaiming

优化币种搜索条件

parent 2d1841c5
......@@ -5,6 +5,7 @@ import (
"bwallet/pkg/util"
"encoding/json"
"github.com/jinzhu/gorm"
"strconv"
)
type Coin struct {
......@@ -82,7 +83,7 @@ func GetCoinTotal(maps interface{}) (int, error) {
if 0 == platform_id {
err = db.Model(&Coin{}).Where(term).Count(&count).Error
} else {
err = db.Model(&Coin{}).Where("JSON_CONTAINS(?, platform_id)", platform_id).Where(term).Count(&count).Error
err = db.Model(&Coin{}).Where("JSON_CONTAINS(platform_id, ?)", strconv.Itoa(platform_id)).Where(term).Count(&count).Error
}
if err != nil {
return 0, err
......@@ -123,7 +124,7 @@ func GetCoins(pageNum, pageSize int, maps interface{}) ([]*Coin, error) {
if 0 == platform_id {
err = db.Where(term).Offset(pageNum).Limit(pageSize).Find(&coins).Error
} else {
err = db.Where("JSON_CONTAINS(?, platform_id)", platform_id).Where(term).Offset(pageNum).Limit(pageSize).Find(&coins).Error
err = db.Where("JSON_CONTAINS(platform_id, ?)", strconv.Itoa(platform_id)).Where(term).Offset(pageNum).Limit(pageSize).Find(&coins).Error
}
if err != nil && err != gorm.ErrRecordNotFound {
......
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 to comment