mirror of
https://gitee.com/best_handsome/mybatis-plus-join
synced 2025-07-11 00:02:22 +08:00
code style
This commit is contained in:
parent
13ec6499e4
commit
181664ed42
@ -13,22 +13,14 @@ import java.util.List;
|
||||
* @author yulichang
|
||||
* @see AbstractMethod
|
||||
*/
|
||||
public abstract class MPJAbstractMethod extends AbstractMethod {
|
||||
public abstract class MPJAbstractMethod extends AbstractMethod implements MPJBaseMethod {
|
||||
|
||||
/**
|
||||
* 连表操作不考虑entity查询和逻辑删除
|
||||
*/
|
||||
@Override
|
||||
protected String sqlWhereEntityWrapper(boolean newLine, TableInfo table) {
|
||||
String sqlScript = SqlScriptUtils.convertIf(String.format("${%s}", WRAPPER_SQLSEGMENT),
|
||||
String.format("%s != null and %s != '' and %s", WRAPPER_SQLSEGMENT, WRAPPER_SQLSEGMENT,
|
||||
WRAPPER_NONEMPTYOFWHERE), true);
|
||||
sqlScript = SqlScriptUtils.convertWhere(sqlScript) + NEWLINE;
|
||||
sqlScript += SqlScriptUtils.convertIf(String.format(" ${%s}", WRAPPER_SQLSEGMENT),
|
||||
String.format("%s != null and %s != '' and %s", WRAPPER_SQLSEGMENT, WRAPPER_SQLSEGMENT,
|
||||
WRAPPER_EMPTYOFWHERE), true);
|
||||
sqlScript = SqlScriptUtils.convertIf(sqlScript, String.format("%s != null", WRAPPER), true);
|
||||
return newLine ? NEWLINE + sqlScript : sqlScript;
|
||||
return whereEntityWrapper(newLine);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
26
src/main/java/com/github/yulichang/method/MPJBaseMethod.java
Normal file
26
src/main/java/com/github/yulichang/method/MPJBaseMethod.java
Normal file
@ -0,0 +1,26 @@
|
||||
package com.github.yulichang.method;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.core.toolkit.sql.SqlScriptUtils;
|
||||
|
||||
/**
|
||||
* 连表sql条件
|
||||
*
|
||||
* @author yulichang
|
||||
* @since 1.2.0
|
||||
*/
|
||||
public interface MPJBaseMethod extends Constants {
|
||||
|
||||
default String whereEntityWrapper(boolean newLine) {
|
||||
String sqlScript = SqlScriptUtils.convertIf(String.format("${%s}", WRAPPER_SQLSEGMENT),
|
||||
String.format("%s != null and %s != '' and %s", WRAPPER_SQLSEGMENT, WRAPPER_SQLSEGMENT,
|
||||
WRAPPER_NONEMPTYOFWHERE), true);
|
||||
sqlScript = SqlScriptUtils.convertWhere(sqlScript) + NEWLINE;
|
||||
sqlScript += SqlScriptUtils.convertIf(String.format(" ${%s}", WRAPPER_SQLSEGMENT),
|
||||
String.format("%s != null and %s != '' and %s", WRAPPER_SQLSEGMENT, WRAPPER_SQLSEGMENT,
|
||||
WRAPPER_EMPTYOFWHERE), true);
|
||||
sqlScript = SqlScriptUtils.convertIf(sqlScript, String.format("%s != null", WRAPPER), true);
|
||||
return newLine ? NEWLINE + sqlScript : sqlScript;
|
||||
}
|
||||
|
||||
}
|
@ -3,6 +3,7 @@ package com.github.yulichang.method.mp;
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.core.toolkit.sql.SqlScriptUtils;
|
||||
import com.github.yulichang.method.MPJBaseMethod;
|
||||
import com.github.yulichang.toolkit.Constant;
|
||||
|
||||
/**
|
||||
@ -11,7 +12,7 @@ import com.github.yulichang.toolkit.Constant;
|
||||
* @author yulichang
|
||||
* @since 1.2.0
|
||||
*/
|
||||
public interface TableAlias extends Constants {
|
||||
public interface TableAlias extends Constants, MPJBaseMethod {
|
||||
|
||||
default String getTableName(TableInfo tableInfo) {
|
||||
return tableInfo.getTableName() + SPACE + SqlScriptUtils.convertIf("${ew.alias}",
|
||||
@ -38,15 +39,7 @@ public interface TableAlias extends Constants {
|
||||
sqlScript = SqlScriptUtils.convertWhere(sqlScript);
|
||||
return newLine ? NEWLINE + sqlScript : sqlScript;
|
||||
} else {
|
||||
String sqlScript = SqlScriptUtils.convertIf(String.format("${%s}", WRAPPER_SQLSEGMENT),
|
||||
String.format("%s != null and %s != '' and %s", WRAPPER_SQLSEGMENT, WRAPPER_SQLSEGMENT,
|
||||
WRAPPER_NONEMPTYOFWHERE), true);
|
||||
sqlScript = SqlScriptUtils.convertWhere(sqlScript) + NEWLINE;
|
||||
sqlScript += SqlScriptUtils.convertIf(String.format(" ${%s}", WRAPPER_SQLSEGMENT),
|
||||
String.format("%s != null and %s != '' and %s", WRAPPER_SQLSEGMENT, WRAPPER_SQLSEGMENT,
|
||||
WRAPPER_EMPTYOFWHERE), true);
|
||||
sqlScript = SqlScriptUtils.convertIf(sqlScript, String.format("%s != null", WRAPPER), true);
|
||||
return newLine ? NEWLINE + sqlScript : sqlScript;
|
||||
return whereEntityWrapper(newLine);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user