Search in sources :

Example 1 with PageVo

use of com.example.forum.vo.PageVo in project forum by saysky.

the class PageUtil method convertPageVo.

/**
 * 设计缺陷,前端无法获取mybatis-plus的分页page中的pages,所以自己封装一个PageVO
 * 同时将分页信息塞到PageVo中
 *
 * @param page mybatis-plus分页类
 * @return
 */
public static PageVo convertPageVo(Page page) {
    PageVo pageVo = new PageVo();
    pageVo.setSize(page.getSize());
    pageVo.setTotal(page.getTotal());
    pageVo.setCurrent(page.getCurrent());
    pageVo.setPages(page.getPages());
    List<OrderItem> orderItems = page.getOrders();
    if (orderItems != null && orderItems.size() > 0) {
        pageVo.setSort(orderItems.get(0).getColumn());
        pageVo.setOrder(orderItems.get(0).isAsc() ? "asc" : "desc");
    }
    return pageVo;
}
Also used : PageVo(com.example.forum.vo.PageVo) OrderItem(com.baomidou.mybatisplus.core.metadata.OrderItem)

Aggregations

OrderItem (com.baomidou.mybatisplus.core.metadata.OrderItem)1 PageVo (com.example.forum.vo.PageVo)1