mirror of
https://gitee.com/best_handsome/mybatis-plus-join
synced 2025-07-11 00:02:22 +08:00
添加around
This commit is contained in:
parent
750b216156
commit
44a726ace8
@ -313,7 +313,7 @@ public abstract class KtAbstractWrapper<T, Children extends KtAbstractWrapper<T,
|
|||||||
@Override
|
@Override
|
||||||
public Children last(boolean condition, String lastSql) {
|
public Children last(boolean condition, String lastSql) {
|
||||||
if (condition) {
|
if (condition) {
|
||||||
this.lastSql.setStringValue(StringPool.SPACE + lastSql);
|
this.lastSql.setStringValue(this.lastSql.getStringValue() + StringPool.SPACE + lastSql);
|
||||||
}
|
}
|
||||||
return typedThis;
|
return typedThis;
|
||||||
}
|
}
|
||||||
@ -329,11 +329,18 @@ public abstract class KtAbstractWrapper<T, Children extends KtAbstractWrapper<T,
|
|||||||
@Override
|
@Override
|
||||||
public Children first(boolean condition, String firstSql) {
|
public Children first(boolean condition, String firstSql) {
|
||||||
if (condition) {
|
if (condition) {
|
||||||
this.sqlFirst.setStringValue(firstSql);
|
this.sqlFirst.setStringValue(firstSql + StringPool.SPACE + this.sqlFirst.getStringValue());
|
||||||
}
|
}
|
||||||
return typedThis;
|
return typedThis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Children around(boolean condition, String firstSql, String lastSql) {
|
||||||
|
this.first(condition, firstSql);
|
||||||
|
this.last(condition, lastSql);
|
||||||
|
return typedThis;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Children exists(boolean condition, String existsSql, Object... values) {
|
public Children exists(boolean condition, String existsSql, Object... values) {
|
||||||
return maybeDo(condition, () -> appendSqlSegments(EXISTS,
|
return maybeDo(condition, () -> appendSqlSegments(EXISTS,
|
||||||
|
@ -333,7 +333,7 @@ public abstract class JoinAbstractWrapper<T, Children extends JoinAbstractWrappe
|
|||||||
@Override
|
@Override
|
||||||
public Children last(boolean condition, String lastSql) {
|
public Children last(boolean condition, String lastSql) {
|
||||||
if (condition) {
|
if (condition) {
|
||||||
this.lastSql.setStringValue(StringPool.SPACE + lastSql);
|
this.lastSql.setStringValue(this.lastSql.getStringValue() + StringPool.SPACE + lastSql);
|
||||||
}
|
}
|
||||||
return typedThis;
|
return typedThis;
|
||||||
}
|
}
|
||||||
@ -349,11 +349,18 @@ public abstract class JoinAbstractWrapper<T, Children extends JoinAbstractWrappe
|
|||||||
@Override
|
@Override
|
||||||
public Children first(boolean condition, String firstSql) {
|
public Children first(boolean condition, String firstSql) {
|
||||||
if (condition) {
|
if (condition) {
|
||||||
this.sqlFirst.setStringValue(firstSql);
|
this.sqlFirst.setStringValue(firstSql + StringPool.SPACE + this.sqlFirst.getStringValue());
|
||||||
}
|
}
|
||||||
return typedThis;
|
return typedThis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Children around(boolean condition, String firstSql, String lastSql) {
|
||||||
|
this.first(condition, firstSql);
|
||||||
|
this.last(condition, lastSql);
|
||||||
|
return typedThis;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Children exists(boolean condition, String existsSql, Object... values) {
|
public Children exists(boolean condition, String existsSql, Object... values) {
|
||||||
return maybeDo(condition, () -> appendSqlSegments(EXISTS,
|
return maybeDo(condition, () -> appendSqlSegments(EXISTS,
|
||||||
|
@ -197,6 +197,18 @@ public class MPJLambdaWrapper<T> extends JoinAbstractLambdaWrapper<T, MPJLambdaW
|
|||||||
return Query.super.selectAll(clazz);
|
return Query.super.selectAll(clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询主表全部字段
|
||||||
|
* <p>
|
||||||
|
* 需要使用 使用 JoinWrappers.lambda(clazz) 或者 new MPJLambdaQueryWrapper<<(clazz) 构造
|
||||||
|
*
|
||||||
|
* @return children
|
||||||
|
*/
|
||||||
|
public MPJLambdaWrapper<T> selectAll() {
|
||||||
|
Assert.notNull(getEntityClass(), "使用 JoinWrappers.lambda(clazz) 或者 new MPJLambdaQueryWrapper<>(clazz)");
|
||||||
|
return selectAll(getEntityClass());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 子查询
|
* 子查询
|
||||||
*/
|
*/
|
||||||
|
@ -97,6 +97,24 @@ public interface Join<Children> extends Serializable {
|
|||||||
*/
|
*/
|
||||||
Children first(boolean condition, String firstSql);
|
Children first(boolean condition, String firstSql);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ignore
|
||||||
|
*/
|
||||||
|
default Children around(String firstSql, String lastSql) {
|
||||||
|
return around(true, firstSql, lastSql);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sql 起始句 和介绍语句(会拼接在SQL语句的起始处和结束处)
|
||||||
|
*
|
||||||
|
* @param condition 执行条件
|
||||||
|
* @param firstSql 起始语句
|
||||||
|
* @param lastSql 结束语句
|
||||||
|
* @return children
|
||||||
|
* @since 1.4.11
|
||||||
|
*/
|
||||||
|
Children around(boolean condition, String firstSql, String lastSql);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ignore
|
* ignore
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user