package cn.axzo.msg.center.util;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

/**
 * @author yanglin
 */
public interface IterableMapper<T> extends BaseMapper<T> {

    // 注意自己的分页插件有没有限制分页的最大条数
    int DEFAULT_BATCH_SIZE = 2000;

    default Iterable<Page<T>> iterateBath(LambdaQueryWrapper<T> query) {
        return RecordIterable.iterateBath(this, DEFAULT_BATCH_SIZE, query);
    }

    default Iterable<Page<T>> iterateBath(long pageSize, LambdaQueryWrapper<T> query) {
        return RecordIterable.iterateBath(this, pageSize, query);
    }

    default Iterable<T> iterateElement(LambdaQueryWrapper<T> query) {
        return RecordIterable.iterateElement(this, DEFAULT_BATCH_SIZE, query);
    }

    default Iterable<T> iterateElement(long pageSize, LambdaQueryWrapper<T> query) {
        return RecordIterable.iterateElement(this, pageSize, query);
    }

    default Iterable<Page<T>> iterateBathStickyPage(LambdaQueryWrapper<T> query) {
        return RecordIterable.iterateBathStickyPage(this, DEFAULT_BATCH_SIZE, query);
    }

    default Iterable<Page<T>> iterateBathStickyPage(long pageSize, LambdaQueryWrapper<T> query) {
        return RecordIterable.iterateBathStickyPage(this, pageSize, query);
    }

    default Iterable<T> iterateElementStickyPage(LambdaQueryWrapper<T> query) {
        return RecordIterable.iterateElementStickyPage(this, DEFAULT_BATCH_SIZE, query);
    }

    default Iterable<T> iterateElementStickyPage(long pageSize, LambdaQueryWrapper<T> query) {
        return RecordIterable.iterateElementStickyPage(this, pageSize, query);
    }

}