mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-12-24 19:59:31 +08:00
排序优化
This commit is contained in:
@@ -40,11 +40,18 @@ public class ResourceServiceImpl extends ServiceImpl<ResourceMapper, Resource> i
|
||||
wrapper.in("category_id", Arrays.asList(filter.getCategoryIds()));
|
||||
}
|
||||
|
||||
// 排序
|
||||
if (filter.getSortAlgo().equals("desc")) {
|
||||
wrapper.orderByDesc(filter.getSortField());
|
||||
String sortFiled = filter.getSortField();
|
||||
if (sortFiled == null || sortFiled.trim().length() == 0) {
|
||||
sortFiled = "id";
|
||||
}
|
||||
String sortAlgo = filter.getSortAlgo();
|
||||
if (sortAlgo == null || sortAlgo.trim().length() == 0) {
|
||||
sortAlgo = "desc";
|
||||
}
|
||||
if ("desc".equals(sortAlgo)) {
|
||||
wrapper.orderByDesc(sortFiled);
|
||||
} else {
|
||||
wrapper.orderByAsc(filter.getSortField());
|
||||
wrapper.orderByAsc(sortFiled);
|
||||
}
|
||||
|
||||
IPage<Resource> adminPage = new Page<>(page, size);
|
||||
|
||||
Reference in New Issue
Block a user