fix 修复排序bug

This commit is contained in:
timerzz 2024-09-12 20:16:40 +08:00
parent 5adbffc9a1
commit de9650b26b

View File

@ -111,8 +111,10 @@ func (f *FindArticleQuery) Scope(db *gorm.DB) *gorm.DB {
if f.Available != nil {
db = db.Where("available=?", *f.Available)
}
if f.RateSort != "" {
db = db.Order("rate " + f.RateSort)
if f.RateSort == "descend" {
db = db.Order("rate desc")
} else if f.RateSort == "ascend" {
db = db.Order("rate asc")
}
return db
}