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

com.gitee.cn9750wang.webtools.vo.page.MybatisPlusPage 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 com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.gitee.cn9750wang.webtools.query.Sort;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;

/**
 * @author wwy
 */
public class MybatisPlusPage implements IPage, Serializable {


    /**
     * 查询数据列表
     */
    private List records = Collections.emptyList();

    /**
     * 总数
     */
    private long total = 0;
    /**
     * 每页显示条数
     */
    private long size;

    private List orders;

    /**
     * 当前页
     */
    private long current = 1;

    public MybatisPlusPage(long current, long size) {
        if (current > 1) {
            this.current = current;
        }
        this.size = size;
    }

    public void setOrders(Sort sort){
        if(sort != null){
            orders = Collections.singletonList(new OrderItem(sort.getField(), sort.isAsc()));
        }
    }

    @Override
    public List orders() {
        return this.orders != null ? this.orders : Collections.emptyList();
    }

    @Override
    public List getRecords() {
        return this.records;
    }

    @Override
    public MybatisPlusPage setRecords(List records) {
        this.records = records;
        return this;
    }

    @Override
    public long getTotal() {
        return this.total;
    }

    @Override
    public MybatisPlusPage setTotal(long total) {
        this.total = total;
        return this;
    }

    @Override
    public long getSize() {
        return this.size;
    }

    @Override
    public MybatisPlusPage setSize(long size) {
        this.size = size;
        return this;
    }

    @Override
    public long getCurrent() {
        return this.current;
    }

    @Override
    public MybatisPlusPage setCurrent(long current) {
        this.current = current;
        return this;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy