Commit d01b2880 authored by shajiaiming's avatar shajiaiming

fix

parent 27ceb447
......@@ -68,8 +68,13 @@ func GetCoinTotal(maps interface{}) (int, error) {
term[key] = val
}
}
if err := db.Model(&Coin{}).Where("FIND_IN_SET(?, platform_id)", platform_id).Where(term).Count(&count).Error; err != nil {
var err error
if 0 == platform_id {
err = db.Model(&Coin{}).Where(term).Count(&count).Error
} else {
err = db.Model(&Coin{}).Where("FIND_IN_SET(?, platform_id)", platform_id).Where(term).Count(&count).Error
}
if err != nil {
return 0, err
}
......@@ -93,7 +98,12 @@ func GetCoins(pageNum, pageSize int, maps interface{}) ([]*Coin, error) {
}
}
err := db.Where("FIND_IN_SET(?, platform_id)", platform_id).Where(term).Offset(pageNum).Limit(pageSize).Find(&coins).Error
var err error
if 0 == platform_id {
err = db.Where(term).Offset(pageNum).Limit(pageSize).Find(&coins).Error
} else {
err = db.Where("FIND_IN_SET(?, platform_id)", platform_id).Where(term).Offset(pageNum).Limit(pageSize).Find(&coins).Error
}
if err != nil && err != gorm.ErrRecordNotFound {
return nil, err
......
......@@ -12,7 +12,7 @@ func Setup() {
func ToInt(o interface{}) int {
if o == nil {
return 0
return 1
}
switch t := o.(type) {
case float64:
......
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