Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
fioman committed Nov 5, 2020
1 parent 0b94f7e commit b1506ab
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions domain/repository/gorm/cursor_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,35 +36,35 @@ func gormCursorFilter(queryHandler *_gorm.DB, ms *_gorm.ModelStruct, query *mode
{
if query.Direction == 0 {
// 游标前
orderBy = fmt.Sprintf("%s %s", sortKey, "ASC")
orderBy = fmt.Sprintf("`%s` %s", sortKey, "ASC")
reverse = true
if query.Cursor != nil {
queryHandler = queryHandler.Where(fmt.Sprintf("%s > ?", sortKey), value)
queryHandler = queryHandler.Where(fmt.Sprintf("`%s` > ?", sortKey), value)
}
} else {
// 游标后
orderBy = fmt.Sprintf("%s %s", sortKey, "DESC")
orderBy = fmt.Sprintf("`%s` %s", sortKey, "DESC")
reverse = false
if query.Cursor != nil {
queryHandler = queryHandler.Where(fmt.Sprintf("%s > ?", sortKey), value)
queryHandler = queryHandler.Where(fmt.Sprintf("`%s` > ?", sortKey), value)
}
}
}
default: // SortType_ASC
{
if query.Direction == 0 {
// 游标前
orderBy = fmt.Sprintf("%s %s", sortKey, "DESC")
orderBy = fmt.Sprintf("`%s` %s", sortKey, "DESC")
reverse = true
if query.Cursor != nil {
queryHandler = queryHandler.Where(fmt.Sprintf("%s > ?", sortKey), value)
queryHandler = queryHandler.Where(fmt.Sprintf("`%s` > ?", sortKey), value)
}
} else {
// 游标后
orderBy = fmt.Sprintf("%s %s", sortKey, "ASC")
orderBy = fmt.Sprintf("`%s` %s", sortKey, "ASC")
reverse = false
if query.Cursor != nil {
queryHandler = queryHandler.Where(fmt.Sprintf("%s > ?", sortKey), value)
queryHandler = queryHandler.Where(fmt.Sprintf("`%s` > ?", sortKey), value)
}
}
}
Expand Down

0 comments on commit b1506ab

Please sign in to comment.