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

cn.cloudself.demo.java.dao.zz.ZzSettingQueryPro Maven / Gradle / Ivy

There is a newer version: 1.4.3
Show newest version
package cn.cloudself.demo.java.dao.zz;

import cn.cloudself.query.util.log.Log;
import cn.cloudself.query.util.log.LogFactory;
import cn.cloudself.demo.java.entity.ZzSetting;
import cn.cloudself.query.*;
import cn.cloudself.query.psi.*;
import cn.cloudself.query.psi.structure.*;
import cn.cloudself.query.exception.IllegalCall;
import cn.cloudself.query.util.iterator.ListEx;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;

import java.util.function.Function;
import java.util.List;
import java.util.Map;

@SuppressWarnings("unused")
public class ZzSettingQueryPro {
    private static final Log logger = LogFactory.getLog(__Impl.class);

    private static QueryStructure defQueryStructure() {
        final QueryStructure queryStructure = new QueryStructure();
        queryStructure.from(new QueryStructureFrom(__Impl.TABLE_NAME));
        return queryStructure;
    }

    private static QueryPro<
            ZzSetting,
            Long,
            __Impl.WhereField>,
            __Impl.OrderByField>,
            __Impl.UpdateSetField,
            __Impl.WhereField,
            __Impl.WhereField
    > createQuery() {
        return new QueryPro<>(
                ZzSettingQueryPro.class,
                ZzSetting.class,
                defQueryStructure(),
                (qs, payload) -> new __Impl.WhereField<>(qs, payload, ZzSetting.class),
                (qs, payload) -> new __Impl.OrderByField<>(qs, payload, ZzSetting.class),
                __Impl.UpdateSetField::new,
                (qs, payload) -> new __Impl.WhereField<>(qs, payload, Boolean.class),
                (qs, payload) -> new __Impl.WhereField<>(qs, payload, Boolean.class)
        );
    }

    public static cn.cloudself.query.QueryPro>, __Impl.OrderByField>, __Impl.UpdateSetField, __Impl.WhereField, __Impl.WhereField> bt(boolean arg0) {
        return createQuery().bt(arg0);
    }

    public static cn.cloudself.query.QueryPro>, __Impl.OrderByField>, __Impl.UpdateSetField, __Impl.WhereField, __Impl.WhereField> connection(java.sql.Connection arg0) {
        return createQuery().connection(arg0);
    }

    public static cn.cloudself.query.QueryPro>, __Impl.OrderByField>, __Impl.UpdateSetField, __Impl.WhereField, __Impl.WhereField> dataSource(javax.sql.DataSource arg0) {
        return createQuery().dataSource(arg0);
    }

    public static cn.cloudself.query.QueryPro>, __Impl.OrderByField>, __Impl.UpdateSetField, __Impl.WhereField, __Impl.WhereField> dbType(cn.cloudself.query.config.IQueryProConfig.DatabaseType arg0) {
        return createQuery().dbType(arg0);
    }

    public static boolean deleteByPrimaryKey(Object arg0) {
        return createQuery().deleteByPrimaryKey(arg0);
    }

    public static __Impl.WhereField deleteBy() {
        return createQuery().deleteBy();
    }

    public static cn.cloudself.query.QueryPro>, __Impl.OrderByField>, __Impl.UpdateSetField, __Impl.WhereField, __Impl.WhereField> dryRun(boolean arg0) {
        return createQuery().dryRun(arg0);
    }

    public static Long insert(ZzSetting arg0) {
        return createQuery().insert(arg0);
    }

    public static java.util.List insert(ZzSetting ...arg0) {
        return createQuery().insert(arg0);
    }

    public static java.util.List insert(java.util.Collection arg0) {
        return createQuery().insert(arg0);
    }

    @SafeVarargs
    public static java.util.List insert(java.util.Map ...arg0) {
        return createQuery().insert(arg0);
    }

    public static cn.cloudself.query.QueryPro>, __Impl.OrderByField>, __Impl.UpdateSetField, __Impl.WhereField, __Impl.WhereField> logicDelete(boolean arg0, String arg1, Object arg2, Object arg3) {
        return createQuery().logicDelete(arg0, arg1, arg2, arg3);
    }

    public static cn.cloudself.query.QueryPro>, __Impl.OrderByField>, __Impl.UpdateSetField, __Impl.WhereField, __Impl.WhereField> logicDelete(boolean arg0) {
        return createQuery().logicDelete(arg0);
    }

    public static cn.cloudself.query.QueryPro>, __Impl.OrderByField>, __Impl.UpdateSetField, __Impl.WhereField, __Impl.WhereField> maxParameterSize(int arg0) {
        return createQuery().maxParameterSize(arg0);
    }

    public static __Impl.OrderByField> orderBy() {
        return createQuery().orderBy();
    }

    public static cn.cloudself.query.QueryPro>, __Impl.OrderByField>, __Impl.UpdateSetField, __Impl.WhereField, __Impl.WhereField> pcb(boolean arg0, cn.cloudself.query.util.log.LogLevel arg1) {
        return createQuery().pcb(arg0, arg1);
    }

    public static cn.cloudself.query.QueryPro>, __Impl.OrderByField>, __Impl.UpdateSetField, __Impl.WhereField, __Impl.WhereField> pcb(boolean arg0) {
        return createQuery().pcb(arg0);
    }

    public static cn.cloudself.query.QueryPro>, __Impl.OrderByField>, __Impl.UpdateSetField, __Impl.WhereField, __Impl.WhereField> pl(boolean arg0, cn.cloudself.query.util.log.LogLevel arg1) {
        return createQuery().pl(arg0, arg1);
    }

    public static cn.cloudself.query.QueryPro>, __Impl.OrderByField>, __Impl.UpdateSetField, __Impl.WhereField, __Impl.WhereField> pl(boolean arg0) {
        return createQuery().pl(arg0);
    }

    public static cn.cloudself.query.QueryPro>, __Impl.OrderByField>, __Impl.UpdateSetField, __Impl.WhereField, __Impl.WhereField> ple(boolean arg0) {
        return createQuery().ple(arg0);
    }

    public static cn.cloudself.query.plus.QueryProPlus plus(String arg0) {
        return createQuery().plus(arg0);
    }

    public static cn.cloudself.query.plus.QueryProPlus plus() {
        return createQuery().plus();
    }

    public static cn.cloudself.query.QueryPro>, __Impl.OrderByField>, __Impl.UpdateSetField, __Impl.WhereField, __Impl.WhereField> pr(boolean arg0, cn.cloudself.query.util.log.LogLevel arg1) {
        return createQuery().pr(arg0, arg1);
    }

    public static cn.cloudself.query.QueryPro>, __Impl.OrderByField>, __Impl.UpdateSetField, __Impl.WhereField, __Impl.WhereField> pr(boolean arg0) {
        return createQuery().pr(arg0);
    }

    public static java.util.List selectAll() {
        return createQuery().selectAll();
    }

    public static __Impl.WhereField> selectByObj(ZzSetting arg0) {
        return createQuery().selectByObj(arg0);
    }

    public static ZzSetting selectByPrimaryKey(Object arg0) {
        return createQuery().selectByPrimaryKey(arg0);
    }

    public static __Impl.WhereField> selectBy() {
        return createQuery().selectBy();
    }

    @Contract(pure = true)
    public static cn.cloudself.query.psi.UpdateSetDefinedExpression<__Impl.WhereField> updateSet(ZzSetting arg0, boolean arg1) {
        return createQuery().updateSet(arg0, arg1);
    }

    @Contract(pure = true)
    public static cn.cloudself.query.psi.UpdateSetDefinedExpression<__Impl.WhereField> updateSet(ZzSetting arg0) {
        return createQuery().updateSet(arg0);
    }

    @Contract(pure = true)
    public static cn.cloudself.query.psi.UpdateSetDefinedExpression<__Impl.WhereField> updateSet(java.util.Map arg0) {
        return createQuery().updateSet(arg0);
    }

    @Contract(pure = true)
    public static __Impl.UpdateSetField updateSet() {
        return createQuery().updateSet();
    }

    public static class __Impl {
        private static final Class CLAZZ = ZzSetting.class;
        public static final String TABLE_NAME = "setting";
        private static Field createField(String column) { return new Field(TABLE_NAME, column); }

        public abstract static class CommonField extends AbstractExpression, OrderByField, ColumnLimiterField, ColumnsLimiterField> {
            protected final QueryStructure queryStructure;
            protected final QueryPayload payload;
            protected final Class clazz;
            CommonField(QueryStructure queryStructure, QueryPayload payload, Class clazz) {
                super();
                this.queryStructure = queryStructure;
                this.payload = payload;
                this.clazz = clazz;
            }
            @NotNull @Override protected QueryStructure getQueryStructure() { return queryStructure; }
            @NotNull @Override public QueryPayload getPayload() { return payload; }
            @NotNull @Override public Class getClazz() { return clazz; }
            @NotNull @Override protected WhereField createWhereField(@NotNull QueryStructure qs, @NotNull QueryPayload payload) { return new WhereField<>(qs, payload, clazz); }
            @NotNull @Override protected OrderByField createOrderByField(@NotNull QueryStructure qs, @NotNull QueryPayload payload) { return new OrderByField<>(qs, payload, clazz); }
            @NotNull @Override protected ColumnLimiterField createColumnLimitField(@NotNull QueryStructure qs, @NotNull QueryPayload payload) { return new ColumnLimiterField<>(qs, payload, clazz); }
            @NotNull @Override protected ColumnsLimiterField createColumnsLimitField(@NotNull QueryStructure qs, @NotNull QueryPayload payload) { return new ColumnsLimiterField<>(qs, payload, clazz); }
        }

        public static class WhereField extends CommonField {
            public WhereField(QueryStructure qs, QueryPayload payload, Class clazz) { super(qs, payload, clazz); }
            @NotNull @Override protected ExpressionType getFieldType() { return ExpressionType.WHERE; }
            private Keywords> createWhereField(String column) {
                return new Keywords<>(new Field(TABLE_NAME, column), queryStructure, payload, super::createWhereField);
            }
            private WhereField createWhereField(String column, Object[] objs) {
                final Keywords> whereField = createWhereField(column);
                return objs.length == 1 ? whereField.equalTo(objs[0]) : whereField.in(objs);
            }

            @Contract(pure = true)
            public Keywords> id() { return createWhereField("id"); }
            @Contract(pure = true)
            public WhereField id(List idList) { return createWhereField("id", idList.toArray(new Object[0])); }
            @Contract(pure = true)
            public WhereField id(Long... ids) { return createWhereField("id", ids); }
            @Contract(pure = true)
            public Keywords> userId() { return createWhereField("user_id"); }
            @Contract(pure = true)
            public WhereField userId(List userIdList) { return createWhereField("user_id", userIdList.toArray(new Object[0])); }
            @Contract(pure = true)
            public WhereField userId(Long... userIds) { return createWhereField("user_id", userIds); }
            @Contract(pure = true)
            public Keywords> kee() { return createWhereField("kee"); }
            @Contract(pure = true)
            public WhereField kee(List keeList) { return createWhereField("kee", keeList.toArray(new Object[0])); }
            @Contract(pure = true)
            public WhereField kee(String... kees) { return createWhereField("kee", kees); }
            @Contract(pure = true)
            public Keywords> value() { return createWhereField("value"); }
            @Contract(pure = true)
            public WhereField value(List valueList) { return createWhereField("value", valueList.toArray(new Object[0])); }
            @Contract(pure = true)
            public WhereField value(String... values) { return createWhereField("value", values); }
            @Contract(pure = true)
            public Keywords> deleted() { return createWhereField("deleted"); }
            @Contract(pure = true)
            public WhereField deleted(List deletedList) { return createWhereField("deleted", deletedList.toArray(new Object[0])); }
            @Contract(pure = true)
            public WhereField deleted(Boolean... deleteds) { return createWhereField("deleted", deleteds); }

            @Contract(pure = true)
            public WhereField take(Function, WhereField> factor) {
                return factor.apply(this);
            }
        }

        public static class OrderByField extends CommonField {
            public OrderByField(QueryStructure qs, QueryPayload payload, Class clazz) { super(qs, payload, clazz); }
            @NotNull @Override protected ExpressionType getFieldType() { return ExpressionType.ORDER_BY; }
            private KeywordsOrderBy> createOrderByField(String column) {
                return new KeywordsOrderBy<>(new Field(TABLE_NAME, column), queryStructure, payload, super::createOrderByField);
            }

            @Contract(pure = true)
            public KeywordsOrderBy> id() { return createOrderByField("id"); }
            @Contract(pure = true)
            public KeywordsOrderBy> userId() { return createOrderByField("user_id"); }
            @Contract(pure = true)
            public KeywordsOrderBy> kee() { return createOrderByField("kee"); }
            @Contract(pure = true)
            public KeywordsOrderBy> value() { return createOrderByField("value"); }
            @Contract(pure = true)
            public KeywordsOrderBy> deleted() { return createOrderByField("deleted"); }

            @Contract(pure = true)
            public OrderByField take(Function, OrderByField> factor) {
                return factor.apply(this);
            }
        }

        public static class ColumnLimiterField extends CommonField {
            public ColumnLimiterField(QueryStructure qs, QueryPayload payload, Class clazz) { super(qs, payload, clazz); }
            @NotNull @Override protected ExpressionType getFieldType() { return ExpressionType.COLUMN_LIMITER; }
            private  ListEx createColumnLimiterField(String column, Class clazz) {
                return new ListEx<>(getColumn(new Field(TABLE_NAME, column), clazz));
            }

            public ListEx id() { return createColumnLimiterField("id", Long.class); }
            public ListEx userId() { return createColumnLimiterField("user_id", Long.class); }
            public ListEx kee() { return createColumnLimiterField("kee", String.class); }
            public ListEx value() { return createColumnLimiterField("value", String.class); }
            public ListEx deleted() { return createColumnLimiterField("deleted", Boolean.class); }

            public  R take(Function, R> factor) {
                return factor.apply(this);
            }
        }

        public static class ColumnsLimiterField extends CommonField {
            public ColumnsLimiterField(QueryStructure qs, QueryPayload payload, Class clazz) { super(qs, payload, clazz); }
            @NotNull @Override protected ExpressionType getFieldType() { return ExpressionType.COLUMNS_LIMITER; }

            @SuppressWarnings("DuplicatedCode")
            private ColumnsLimiterField createColumnsLimiterField(String column) {
                final QueryStructure queryStructure = getQueryStructure();
                queryStructure.appendField(new Field(TABLE_NAME, column));
                return new ColumnsLimiterField<>(queryStructure, payload, clazz);
            }

            @Contract(pure = true)
            public ColumnsLimiterField id() { return createColumnsLimiterField("id"); }
            @Contract(pure = true)
            public ColumnsLimiterField userId() { return createColumnsLimiterField("user_id"); }
            @Contract(pure = true)
            public ColumnsLimiterField kee() { return createColumnsLimiterField("kee"); }
            @Contract(pure = true)
            public ColumnsLimiterField value() { return createColumnsLimiterField("value"); }
            @Contract(pure = true)
            public ColumnsLimiterField deleted() { return createColumnsLimiterField("deleted"); }

            @Contract(pure = true)
            public ColumnsLimiterField take(Function, ColumnsLimiterField> factor) {
                return factor.apply(this);
            }
        }

        public static class UpdateSetField extends UpdateSetDefinedExpression> {
            private final QueryStructure queryStructure;
            public UpdateSetField(QueryStructure qs, QueryPayload payload) {
                super(qs, payload, (q, p) -> new WhereField<>(q, p, Boolean.class));
                this.queryStructure = qs;
            }

            @SuppressWarnings("DuplicatedCode")
            private UpdateSetField createUpdateSetField(String key, Object value) {
                final Update update = queryStructure.update();
                if (update == null) {
                    throw new IllegalCall("usage like: UserQueryPro.updateSet().id(1).name(name).run()");
                }
                if (value == null) {
                    logger.error("null值不能直接updateSet, 使用Const.NULL代替, usage like: UserQueryPro.updateSet().name(Const.NULL).where().id(1).run()");
                }
                @SuppressWarnings("unchecked") final Map map = (Map) update.data();
                assert map != null;
                map.put(key, value);
                return this;
            }

            @Contract(pure = true)
            public UpdateSetField id(Object id) { return createUpdateSetField("id", id); }
            @Contract(pure = true)
            public UpdateSetField userId(Object userId) { return createUpdateSetField("user_id", userId); }
            @Contract(pure = true)
            public UpdateSetField kee(Object kee) { return createUpdateSetField("kee", kee); }
            @Contract(pure = true)
            public UpdateSetField value(Object value) { return createUpdateSetField("value", value); }
            @Contract(pure = true)
            public UpdateSetField deleted(Object deleted) { return createUpdateSetField("deleted", deleted); }

            @Contract(pure = true)
            public UpdateSetField take(Function factor) {
                return factor.apply(this);
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy