fix 修复排序bug
This commit is contained in:
parent
3695565f76
commit
f0a601466b
@ -119,6 +119,8 @@ func (f *FindArticleQuery) SortScope(db *gorm.DB) *gorm.DB {
|
||||
db = db.Order("rate desc")
|
||||
} else if f.RateSort == "ascend" {
|
||||
db = db.Order("rate asc")
|
||||
} else {
|
||||
db = db.Order("id desc")
|
||||
}
|
||||
return db
|
||||
}
|
||||
@ -132,7 +134,7 @@ func (a *articleApi) List(query PageListQuery, scopes ...func(db *gorm.DB) *gorm
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = a.db.Scopes(query.Scope).Scopes(scopes...).Order("id").Find(&articles).Error
|
||||
err = a.db.Scopes(query.Scope).Scopes(scopes...).Find(&articles).Error
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user