Mongo 排序,多個字段排序



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);


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章