Mongo 排序,多個字段排序
Sort sort = null;
List<Order> orderList = new ArrayList<Order>();
if (StringUtils.isNotBlank(req.getOrderTag()) && StringUtils.isNotBlank(req.getOrderDirection())) {
if("ASC".equalsIgnoreCase(req.getOrderDirection())){
Order orderCurrentPrice = new Order(Direction.ASC, req.getOrderTag());
orderList.add(orderCurrentPrice);
}else{
Order orderCurrentPrice = new Order(Direction.DESC, req.getOrderTag());
orderList.add(orderCurrentPrice);
}
} else {
Order orderCurrentPrice = new Order(Direction.DESC, "createDate");
orderList.add(orderCurrentPrice);
}
Order orderCurrentPrice = new Order(Direction.ASC, "id");
orderList.add(orderCurrentPrice);
sort = new Sort(orderList);