Search in sources :

Example 1 with OrderQueryParam

use of co.yixiang.common.web.param.OrderQueryParam in project yshopmall by guchengwuyue.

the class BaseServiceImpl method setPageParam.

protected Page setPageParam(QueryParam queryParam, OrderItem defaultOrder) {
    Page page = new Page();
    // 设置当前页码
    page.setCurrent(queryParam.getPage());
    // 设置页大小
    page.setSize(queryParam.getLimit());
    /**
     * 如果是queryParam是OrderQueryParam,并且不为空,则使用前端排序
     * 否则使用默认排序
     */
    if (queryParam instanceof OrderQueryParam) {
        OrderQueryParam orderQueryParam = (OrderQueryParam) queryParam;
        List<OrderItem> orderItems = orderQueryParam.getOrders();
        if (CollectionUtil.isEmpty(orderItems)) {
            page.setOrders(Arrays.asList(defaultOrder));
        } else {
            page.setOrders(orderItems);
        }
    } else {
        page.setOrders(Arrays.asList(defaultOrder));
    }
    return page;
}
Also used : OrderQueryParam(co.yixiang.common.web.param.OrderQueryParam) OrderItem(com.baomidou.mybatisplus.core.metadata.OrderItem) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page)

Aggregations

OrderQueryParam (co.yixiang.common.web.param.OrderQueryParam)1 OrderItem (com.baomidou.mybatisplus.core.metadata.OrderItem)1 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)1