All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.liguanqiao.grow.mybaits.puls.converts.MybatisPlusPageConverts Maven / Gradle / Ivy

There is a newer version: 0.2.1
Show newest version
package com.liguanqiao.grow.mybaits.puls.converts;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
import com.liguanqiao.grow.core.model.req.PageReq;
import com.liguanqiao.grow.core.model.resp.PageResp;

import java.util.List;

/**
 * @author liguanqiao
 * @since 2022/12/20
 **/
public interface MybatisPlusPageConverts {

    static  IPage convert(PageReq req) {
        return convert(req, Boolean.TRUE);
    }

    static  IPage convert(PageReq req, boolean searchCount) {
        return PageDTO.of(req.getPageCur(), req.getPageSize(), searchCount);
    }

    static  PageResp convert(IPage page, List records) {
        PageResp result = new PageResp<>();
        result.setPageCur((int) page.getCurrent());
        result.setPageSize((int) page.getSize());
        result.setPages((int) page.getPages());
        result.setTotal(page.getTotal());
        result.setList(records);
        return result;
    }

    static  PageResp convert(IPage page) {
        PageResp result = new PageResp<>();
        result.setPageCur((int) page.getCurrent());
        result.setPageSize((int) page.getSize());
        result.setPages((int) page.getPages());
        result.setTotal(page.getTotal());
        result.setList(page.getRecords());
        return result;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy