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

com.gitee.cn9750wang.webtools.vo.page.Page Maven / Gradle / Ivy

The newest version!
/*
 *    Copyright 2021 wwy
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */
package com.gitee.cn9750wang.webtools.vo.page;

import com.baomidou.mybatisplus.core.metadata.IPage;

import java.io.Serializable;
import java.util.Collection;

/**
 * 分页结果
 *
 * @param  数据项的类型
 * @author anonym
 */
public interface Page extends Serializable {


    /**
     * 获取空分页对象实例
     * @param  数据项数据类型
     * @return 空分页对象实例
     */
    @SuppressWarnings({"unchecked"})
    static  Page emptyPage(){
        return (Page) EmptyPage.emptyPage();
    }

    /**
     * 查询数据列表
     * @return 查询数据列表
     */
    Collection getItems();

    /**
     * 符合条件的数据总数
     * @return 符合条件的数据总数
     */
    long getTotal();

    /**
     * 当前页
     * @return 当前页
     */
    long getPage();

    /**
     * mybatis-plus 分页对象转换为标准分页对象
     * @param page 原始分页对象
     * @param  数据类型
     * @return 分页对象
     */
    @SuppressWarnings({"unchecked"})
    static  Page to(IPage page){
        if(page == null || page.getTotal() <= 0){
            return (Page) EmptyPage.emptyPage();
        }
        var myPage = new PageImpl();
        myPage.setPage(page.getCurrent());
        myPage.setTotal(page.getTotal());
        myPage.setItems(page.getRecords());
        return myPage;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy