Mongo 排序,多个字段排序

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

Mongo 排序,多个字段排序

Sort sort = null;
	List orderList = new ArrayList();
	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);

 

转载于:https://my.oschina.net/airship/blog/3013567

你可能感兴趣的:(Mongo 排序,多个字段排序)