package com.yeshi.fanli.util.db;
|
|
import org.springframework.data.domain.Sort;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
|
/**
|
* @author Administrator
|
* @title: MongoSortFactory
|
* @description: mongodb排序转换
|
* @date 2021/9/13 19:13
|
*/
|
public class MongoSortFactory {
|
|
|
public static List<Sort.Order> createFromSqlSort(List<String> sortList) {
|
if (sortList == null || sortList.size() == 0)
|
return null;
|
List<Sort.Order> sortOrderList = new ArrayList<>();
|
for (String st : sortList) {
|
String[] sts = st.trim().split(" ");
|
if (sts.length < 2)
|
continue;
|
sortOrderList.add(new Sort.Order(Sort.Direction.valueOf(sts[1].toUpperCase()), sts[0]));
|
}
|
|
return sortOrderList;
|
}
|
|
|
}
|