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

io.github.davidchild.bitter.op.page.UnionPage Maven / Gradle / Ivy

package io.github.davidchild.bitter.op.page;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import io.github.davidchild.bitter.basequery.BaseQuery;
import io.github.davidchild.bitter.basequery.ExecuteMode;

public class UnionPage extends BaseQuery implements IUnionPageAccess {

    private Integer totalCount;
    private List unionQueryList = new ArrayList<>();

    /// 
    /// Total number of collections
    /// 
    public Integer getCount() {

        int sum = 0;
        for (IPageAccess page : unionQueryList) {
            sum += page.getCount();
        }
        return sum;

    }

    /// 
    /// Current page
    /// 
    /// 
    public IUnionPageAccess skip(Integer pageIndex) {
        for (IPageAccess page : unionQueryList) {
            page.skip(pageIndex);
        }
        return this;
    }

    /// 
    /// How many are displayed per page
    /// 
    /// 
    public IUnionPageAccess take(Integer pageSize) {
        for (IPageAccess page : unionQueryList) {
            page.take(pageSize);
        }
        return this;
    }

    public IUnionPageAccess thenASC(String filedName) {
        for (IPageAccess page : unionQueryList) {
            page.thenASC(filedName);
        }
        return this;
    }

    public IUnionPageAccess thenDESC(String filedName) {
        for (IPageAccess page : unionQueryList) {
            page.thenDESC(filedName);
        }
        return this;
    }

    /// 
    /// Find set data
    /// 
    /// 
    public List> getData() {
        List> DRS = new ArrayList<>();;
        for (IPageAccess page : unionQueryList) {
            DRS.addAll(page.getData());
        }
        return DRS;
    }

    /// 
    /// Statement of the associated collection
    /// 
    /// Incorporated into a collection
    /// 
    public IUnionPageAccess union(IPageAccess page) {
        unionQueryList.add(page);
        return this;
    }

    /// 
    /// Associated Collection List
    /// 
    /// Incorporated into a collection
    /// 
    public IUnionPageAccess union(List listPage) {
        unionQueryList.addAll(listPage);
        return this;
    }

    /// 
    /// Return to SetWhere
    /// 
    /// 
    /// 
    public IUnionPageAccess where(String setWhere, Object... dynamicParams) {
        for (IPageAccess page : unionQueryList) {
            page.where(setWhere, dynamicParams);
        }
        return this;
    }

    /// 
    /// setWhere
    /// 
    /// 
    public IUnionPageAccess where(String setWhere) {
        for (IPageAccess page : unionQueryList) {
            page.where(setWhere);
        }
        return this;
    }

    /// 
    /// Or; Note: At this time, Or is always in parallel with the precondition
    /// For example: 1: ((x.y=="1") or (x.z=3)) or (x.n=4)
    /// For example: 2: ((x.y=="1") and (x.z=3)) or (x.n=4)
    /// It must be noted that there is no such writing method: (x.y=="1") and (x.z=3) or (x.n=4), so as to eliminate
    /// this wrong writing method
    /// 
    /// 
    public IUnionPageAccess or(String setOr) {
        for (IPageAccess page : unionQueryList) {
            page.or(setOr);
        }
        return this;
    }

    /// 
    /// Or; Note: At this time, Or is always in parallel with the precondition
    /// For example: 1: ((x.y=="1") or (x.z=3)) or (x.n=4)
    /// For example: 2: ((x.y=="1") and (x.z=3)) or (x.n=4)
    /// It must be noted that there is no such writing method: (x.y=="1") and (x.z=3) or (x.n=4), so as to eliminate
    /// this wrong writing method
    /// 
    /// 
    public IUnionPageAccess or(String setOr, Object... dynamicParams) {
        for (IPageAccess page : unionQueryList) {
            page.or(setOr, dynamicParams);
        }
        return this;
    }

    public IUnionPageAccess addPreWith(String withSql) {
        for (IPageAccess page : unionQueryList) {
            page.addPreWith(withSql);
        }
        return this;
    }

    public IUnionPageAccess addPreWith(String withSql, Object... params) {
        for (IPageAccess page : unionQueryList) {
            page.addPreWith(withSql, params);
        }
        return this;
    }

    public IUnionPageAccess setExecuteMode(ExecuteMode executeMode) {
        for (IPageAccess page : unionQueryList) {
            page.setExecuteMode(executeMode);
        }
        return this;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy