com.github.yulichang.wrapper.interfaces.Func Maven / Gradle / Ivy
Show all versions of mybatis-plus-join-core Show documentation
package com.github.yulichang.wrapper.interfaces;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.function.Consumer;
/**
* 将原来的泛型R改成SFunction
*
* copy {@link com.baomidou.mybatisplus.core.conditions.interfaces.Func}
*/
@SuppressWarnings({"unchecked", "unused", "JavadocDeclaration"})
public interface Func extends Serializable {
/**
* ignore
*/
@SuppressWarnings("UnusedReturnValue")
default Children isNull(SFunction column) {
return isNull(true, column);
}
/**
* 字段 IS NULL
* 例: isNull("name")
*
* @param condition 执行条件
* @param column 字段
* @return children
*/
Children isNull(boolean condition, SFunction column);
/**
* ignore
*/
default Children isNotNull(SFunction column) {
return isNotNull(true, column);
}
/**
* 字段 IS NOT NULL
* 例: isNotNull("name")
*
* @param condition 执行条件
* @param column 字段
* @return children
*/
Children isNotNull(boolean condition, SFunction column);
/**
* ignore
*/
default Children in(SFunction column, Collection> coll) {
return in(true, column, coll);
}
/**
* 字段 IN (value.get(0), value.get(1), ...)
* 例: in("id", Arrays.asList(1, 2, 3, 4, 5))
*
* 注意!集合为空若存在逻辑错误,请在 condition 条件中判断
* 如果集合为 empty 则不会进行 sql 拼接
*
* @param condition 执行条件
* @param column 字段
* @param coll 数据集合
* @return children
*/
Children in(boolean condition, SFunction column, Collection> coll);
/**
* ignore
*/
default Children in(SFunction column, Object... values) {
return in(true, column, values);
}
/**
* 字段 IN (v0, v1, ...)
* 例: in("id", 1, 2, 3, 4, 5)
*
* 注意!数组为空若存在逻辑错误,请在 condition 条件中判断
* 如果动态数组为 empty 则不会进行 sql 拼接
*
* @param condition 执行条件
* @param column 字段
* @param values 数据数组
* @return children
*/
Children in(boolean condition, SFunction column, Object... values);
/**
* ignore
*/
default Children notIn(SFunction column, Collection> coll) {
return notIn(true, column, coll);
}
/**
* 字段 NOT IN (value.get(0), value.get(1), ...)
* 例: notIn("id", Arrays.asList(1, 2, 3, 4, 5))
*
* @param condition 执行条件
* @param column 字段
* @param coll 数据集合
* @return children
*/
Children notIn(boolean condition, SFunction column, Collection> coll);
/**
* ignore
*/
default Children notIn(SFunction column, Object... value) {
return notIn(true, column, value);
}
/**
* 字段 NOT IN (v0, v1, ...)
* 例: notIn("id", 1, 2, 3, 4, 5)
*
* @param condition 执行条件
* @param column 字段
* @param values 数据数组
* @return children
*/
Children notIn(boolean condition, SFunction column, Object... values);
/**
* ignore
*/
default Children inSql(SFunction column, String inValue) {
return inSql(true, column, inValue);
}
/**
* 字段 IN ( sql语句 )
* !! sql 注入方式的 in 方法 !!
* 例1: inSql("id", "1, 2, 3, 4, 5, 6")
* 例2: inSql("id", "select id from table where id < 3")
*
* @param condition 执行条件
* @param column 字段
* @param inValue sql语句
* @return children
*/
Children inSql(boolean condition, SFunction column, String inValue);
/**
* ignore
*/
default Children notInSql(SFunction column, String inValue) {
return notInSql(true, column, inValue);
}
/**
* 字段 NOT IN ( sql语句 )
* !! sql 注入方式的 not in 方法 !!
* 例1: notInSql("id", "1, 2, 3, 4, 5, 6")
* 例2: notInSql("id", "select id from table where id < 3")
*
* @param condition 执行条件
* @param column 字段
* @param inValue sql语句 ---> 1,2,3,4,5,6 或者 select id from table where id < 3
* @return children
*/
Children notInSql(boolean condition, SFunction column, String inValue);
/**
* 字段 > ( sql语句 )
* 例1: gtSql("id", "1, 2, 3, 4, 5, 6")
* 例1: gtSql("id", "select id from table where name = 'JunJun'")
*
* @param condition
* @param column
* @param inValue
* @return
*/
Children gtSql(boolean condition, SFunction column, String inValue);
/**
* ignore
*/
default Children gtSql(SFunction column, String inValue) {
return gtSql(true, column, inValue);
}
/**
* 字段 >= ( sql语句 )
* 例1: geSql("id", "1, 2, 3, 4, 5, 6")
* 例1: geSql("id", "select id from table where name = 'JunJun'")
*
* @param condition
* @param column
* @param inValue
* @return
*/
Children geSql(boolean condition, SFunction column, String inValue);
/**
* ignore
*/
default Children geSql(SFunction column, String inValue) {
return geSql(true, column, inValue);
}
/**
* 字段 < ( sql语句 )
* 例1: ltSql("id", "1, 2, 3, 4, 5, 6")
* 例1: ltSql("id", "select id from table where name = 'JunJun'")
*
* @param condition
* @param column
* @param inValue
* @return
*/
Children ltSql(boolean condition, SFunction column, String inValue);
/**
* ignore
*/
default Children ltSql(SFunction column, String inValue) {
return ltSql(true, column, inValue);
}
/**
* 字段 <= ( sql语句 )
* 例1: leSql("id", "1, 2, 3, 4, 5, 6")
* 例1: leSql("id", "select id from table where name = 'JunJun'")
*
* @param condition
* @param column
* @param inValue
* @return
*/
Children leSql(boolean condition, SFunction column, String inValue);
/**
* ignore
*/
default Children leSql(SFunction column, String inValue) {
return leSql(true, column, inValue);
}
/**
* ignore
*/
default Children groupBy(SFunction column) {
return groupBy(true, column);
}
/**
* ignore
*/
default Children groupBy(List> column) {
return groupBy(true, column);
}
/**
* ignore
*/
Children groupBy(boolean condition, List> columns);
/**
* ignore
*/
default Children groupBy(SFunction column, SFunction... columns) {
return groupBy(true, column, columns);
}
/**
* 分组:GROUP BY 字段, ...
* 例: groupBy("id", "name")
*
* @param condition 执行条件
* @param column 单个字段
* @param columns 字段数组
* @return children
*/
Children groupBy(boolean condition, SFunction column, SFunction... columns);
/**
* ignore
*/
default Children orderByAsc(SFunction column) {
return orderByAsc(true, column);
}
/**
* ignore
*/
default Children orderByAsc(List> columns) {
return orderByAsc(true, columns);
}
/**
* ignore
*/
Children orderByAsc(boolean condition, List> columns);
/**
* ignore
*/
default Children orderByAsc(SFunction column, SFunction... columns) {
return orderByAsc(true, column, columns);
}
/**
* 排序:ORDER BY 字段, ... ASC
* 例: orderByAsc("id", "name")
*
* @param condition 执行条件
* @param column 单个字段
* @param columns 字段数组
* @return children
*/
default Children orderByAsc(boolean condition, SFunction column, SFunction... columns) {
return orderBy(condition, true, column, columns);
}
/**
* ignore
*/
default Children orderByDesc(SFunction column) {
return orderByDesc(true, column);
}
/**
* ignore
*/
default Children orderByDesc(List> columns) {
return orderByDesc(true, columns);
}
/**
* ignore
*/
Children orderByDesc(boolean condition, List> columns);
/**
* ignore
*/
default Children orderByDesc(SFunction column, SFunction... columns) {
return orderByDesc(true, column, columns);
}
/**
* 排序:ORDER BY 字段, ... DESC
* 例: orderByDesc("id", "name")
*
* @param condition 执行条件
* @param column 单个字段
* @param columns 字段数组
* @return children
*/
default Children orderByDesc(boolean condition, SFunction column, SFunction... columns) {
return orderBy(condition, false, column, columns);
}
/**
* 排序:ORDER BY 字段, ...
* 例: orderBy(true, "id", "name")
*
* @param condition 执行条件
* @param isAsc 是否是 ASC 排序
* @param column 单个字段
* @param columns 字段数组
* @return children
*/
Children orderBy(boolean condition, boolean isAsc, SFunction column, SFunction... columns);
/**
* ignore
*/
default Children having(String sqlHaving, Object... params) {
return having(true, sqlHaving, params);
}
/**
* HAVING ( sql语句 )
* 例1: having("sum(age) > 10")
* 例2: having("sum(age) > {0}", 10)
*
* @param condition 执行条件
* @param sqlHaving sql 语句
* @param params 参数数组
* @return children
*/
Children having(boolean condition, String sqlHaving, Object... params);
/**
* ignore
*/
default Children func(Consumer consumer) {
return func(true, consumer);
}
/**
* 消费函数
*
* @param consumer 消费函数
* @return children
* @since 3.3.1
*/
Children func(boolean condition, Consumer consumer);
}