mirror of
https://gitee.com/best_handsome/mybatis-plus-join
synced 2025-07-11 00:02:22 +08:00
fix order by
This commit is contained in:
parent
3a0873cbfd
commit
4158b5a3e0
@ -18,12 +18,12 @@ QQ群:1022221898
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.yulichang</groupId>
|
<groupId>com.github.yulichang</groupId>
|
||||||
<artifactId>mybatis-plus-join-boot-starter</artifactId>
|
<artifactId>mybatis-plus-join-boot-starter</artifactId>
|
||||||
<version>1.4.2</version>
|
<version>1.4.2.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
- Gradle
|
- Gradle
|
||||||
```
|
```
|
||||||
implementation 'com.github.yulichang:mybatis-plus-join-boot-starter:1.4.2'
|
implementation 'com.github.yulichang:mybatis-plus-join-boot-starter:1.4.2.2'
|
||||||
```
|
```
|
||||||
或者clone代码到本地执行 mvn install, 再引入以上依赖
|
或者clone代码到本地执行 mvn install, 再引入以上依赖
|
||||||
<br>
|
<br>
|
||||||
|
@ -7,9 +7,9 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.github.yulichang</groupId>
|
<groupId>com.github.yulichang</groupId>
|
||||||
<artifactId>mybatis-plus-join-root</artifactId>
|
<artifactId>mybatis-plus-join-root</artifactId>
|
||||||
<version>1.4.2</version>
|
<version>1.4.2.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
<version>1.4.2</version>
|
<version>1.4.2.2</version>
|
||||||
<artifactId>mybatis-plus-join-annotation</artifactId>
|
<artifactId>mybatis-plus-join-annotation</artifactId>
|
||||||
<name>mybatis-plus-join-annotation</name>
|
<name>mybatis-plus-join-annotation</name>
|
||||||
|
|
||||||
|
@ -7,9 +7,9 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.github.yulichang</groupId>
|
<groupId>com.github.yulichang</groupId>
|
||||||
<artifactId>mybatis-plus-join-root</artifactId>
|
<artifactId>mybatis-plus-join-root</artifactId>
|
||||||
<version>1.4.2</version>
|
<version>1.4.2.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
<version>1.4.2</version>
|
<version>1.4.2.2</version>
|
||||||
<artifactId>mybatis-plus-join-boot-starter</artifactId>
|
<artifactId>mybatis-plus-join-boot-starter</artifactId>
|
||||||
<name>mybatis-plus-join-boot-starter</name>
|
<name>mybatis-plus-join-boot-starter</name>
|
||||||
|
|
||||||
@ -47,7 +47,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.yulichang</groupId>
|
<groupId>com.github.yulichang</groupId>
|
||||||
<artifactId>mybatis-plus-join-core</artifactId>
|
<artifactId>mybatis-plus-join-core</artifactId>
|
||||||
<version>1.4.2</version>
|
<version>1.4.2.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
@ -7,9 +7,9 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.github.yulichang</groupId>
|
<groupId>com.github.yulichang</groupId>
|
||||||
<artifactId>mybatis-plus-join-root</artifactId>
|
<artifactId>mybatis-plus-join-root</artifactId>
|
||||||
<version>1.4.2</version>
|
<version>1.4.2.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
<version>1.4.2</version>
|
<version>1.4.2.2</version>
|
||||||
<artifactId>mybatis-plus-join-core</artifactId>
|
<artifactId>mybatis-plus-join-core</artifactId>
|
||||||
<name>mybatis-plus-join-core</name>
|
<name>mybatis-plus-join-core</name>
|
||||||
|
|
||||||
@ -47,7 +47,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.yulichang</groupId>
|
<groupId>com.github.yulichang</groupId>
|
||||||
<artifactId>mybatis-plus-join-annotation</artifactId>
|
<artifactId>mybatis-plus-join-annotation</artifactId>
|
||||||
<version>1.4.2</version>
|
<version>1.4.2.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baomidou</groupId>
|
<groupId>com.baomidou</groupId>
|
||||||
|
@ -29,7 +29,7 @@ public class MPJInterceptorConfig {
|
|||||||
//打印banner
|
//打印banner
|
||||||
System.out.println(" _ _ |_ _ _|_. ___ _ | _ . _ . _ \n" +
|
System.out.println(" _ _ |_ _ _|_. ___ _ | _ . _ . _ \n" +
|
||||||
"| | |\\/|_)(_| | |_\\ |_)||_|_\\ | (_) | | | \n" +
|
"| | |\\/|_)(_| | |_\\ |_)||_|_\\ | (_) | | | \n" +
|
||||||
" / | / 1.4.2");
|
" / | / 1.4.2.2");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,11 +235,12 @@ public class MPJInterceptor implements Interceptor {
|
|||||||
String columnName = StringUtils.getTargetColumn(r.getSelectNormal().getColumn());
|
String columnName = StringUtils.getTargetColumn(r.getSelectNormal().getColumn());
|
||||||
SelectLabel label;
|
SelectLabel label;
|
||||||
Field field = ofTypeField.get(r.getProperty());
|
Field field = ofTypeField.get(r.getProperty());
|
||||||
|
String index = mybatisLabel.getIndex();
|
||||||
if (columnSet.contains(columnName)) {
|
if (columnSet.contains(columnName)) {
|
||||||
columnName = getColumn(columnSet, columnName, 0);
|
columnName = getColumn(columnSet, columnName, 0);
|
||||||
label = new SelectLabel(r.getSelectNormal(), mybatisLabel.getIndex(), mybatisLabel.getOfType(), field, columnName);
|
label = new SelectLabel(r.getSelectNormal(), null, mybatisLabel.getOfType(), field, columnName, StringUtils.isNotBlank(index), index);
|
||||||
} else {
|
} else {
|
||||||
label = new SelectLabel(r.getSelectNormal(), mybatisLabel.getIndex(), mybatisLabel.getOfType(), field);
|
label = new SelectLabel(r.getSelectNormal(), null, mybatisLabel.getOfType(), field, StringUtils.isNotBlank(index), index);
|
||||||
}
|
}
|
||||||
columnList.add(label);
|
columnList.add(label);
|
||||||
ResultMapping.Builder builder = new ResultMapping.Builder(ms.getConfiguration(), r.getProperty(), columnName, r.getJavaType());
|
ResultMapping.Builder builder = new ResultMapping.Builder(ms.getConfiguration(), r.getProperty(), columnName, r.getJavaType());
|
||||||
|
@ -20,7 +20,7 @@ public class LogicInfoUtils implements Constants {
|
|||||||
private static final Map<Class<?>, Map<String, String>> LOGIC_CACHE = new ConcurrentHashMap<>();
|
private static final Map<Class<?>, Map<String, String>> LOGIC_CACHE = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
|
||||||
public static String getLogicInfo(String tableIndex, Class<?> clazz, boolean hasAlias, String alias) {
|
public static String getLogicInfo(Integer tableIndex, Class<?> clazz, boolean hasAlias, String alias) {
|
||||||
Map<String, String> absent = LOGIC_CACHE.get(clazz);
|
Map<String, String> absent = LOGIC_CACHE.get(clazz);
|
||||||
if (absent == null) {
|
if (absent == null) {
|
||||||
absent = new ConcurrentHashMap<>();
|
absent = new ConcurrentHashMap<>();
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package com.github.yulichang.toolkit;
|
package com.github.yulichang.toolkit;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class TableList {
|
public class TableList {
|
||||||
@ -19,6 +21,11 @@ public class TableList {
|
|||||||
*/
|
*/
|
||||||
private Class<?> rootClass;
|
private Class<?> rootClass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主表别名
|
||||||
|
*/
|
||||||
|
private String alias;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关联表
|
* 关联表
|
||||||
*/
|
*/
|
||||||
@ -45,19 +52,127 @@ public class TableList {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPrefix(int index) {
|
public String getPrefix(Integer index, Class<?> clazz, boolean isLabel) {
|
||||||
return null;
|
if (Objects.isNull(index)) {
|
||||||
|
if (!isLabel) {
|
||||||
|
if (rootClass == clazz) {
|
||||||
|
return alias;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Node node = getByClassFirst(clazz);
|
||||||
|
if (Objects.isNull(node)) {
|
||||||
|
return alias;
|
||||||
|
}
|
||||||
|
return node.isHasAlias() ? node.getAlias() : (node.getAlias() + node.getIndex());
|
||||||
|
}
|
||||||
|
Node node = getByIndex(index);
|
||||||
|
if (node.getClazz() != clazz) {
|
||||||
|
Node dg = dg(node, clazz);
|
||||||
|
if (Objects.nonNull(dg)) {
|
||||||
|
node = dg;
|
||||||
|
} else {
|
||||||
|
if (rootClass != clazz) {
|
||||||
|
List<Node> list = getByClass(clazz);
|
||||||
|
for (int i = list.size() - 1; i >= 0; i--) {
|
||||||
|
Node n = list.get(i);
|
||||||
|
if (n.getClazz() == clazz) {
|
||||||
|
return n.hasAlias ? n.getAlias() : (n.getAlias() + n.getIndex());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return alias;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (node.hasAlias) {
|
||||||
|
return node.getAlias();
|
||||||
|
} else {
|
||||||
|
return node.getAlias() + node.getIndex();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPrefixOther(int index) {
|
public String getPrefixOther(Integer index, Class<?> clazz) {
|
||||||
return null;
|
if (Objects.isNull(index)) {
|
||||||
|
List<Node> list = getByClass(clazz);
|
||||||
|
if (list.size() == 1 && list.get(0).getClazz() == clazz) {
|
||||||
|
return alias;
|
||||||
|
} else if (list.size() > 1) {
|
||||||
|
for (Node n : list) {
|
||||||
|
if (n.getClazz() == clazz) {
|
||||||
|
return n.isHasAlias() ? n.getAlias() : (n.getAlias() + n.getIndex());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return alias;
|
||||||
|
} else {
|
||||||
|
return alias;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Node node = getByIndex(index);
|
||||||
|
Node dg = dg(node, node.getClazz());
|
||||||
|
if (Objects.nonNull(dg)) {
|
||||||
|
return dg.hasAlias ? dg.alias : (dg.alias + dg.getIndex());
|
||||||
|
}
|
||||||
|
if (Objects.equals(rootClass, node.getClazz())) {
|
||||||
|
return alias;
|
||||||
|
} else {
|
||||||
|
List<Node> list = getByClass(node.getClazz());
|
||||||
|
if (list.size() == 1) {
|
||||||
|
Node n = list.get(0);
|
||||||
|
if (n.getClazz() == node.getClazz()) {
|
||||||
|
return alias;
|
||||||
|
} else {
|
||||||
|
return n.isHasAlias() ? n.getAlias() : (n.getAlias() + n.getIndex());
|
||||||
|
}
|
||||||
|
} else if (list.size() > 1) {
|
||||||
|
for (Node n : list) {
|
||||||
|
if (n.getClazz() != node.getClazz()) {
|
||||||
|
return n.isHasAlias() ? n.getAlias() : (n.getAlias() + n.getIndex());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return alias;
|
||||||
|
} else {
|
||||||
|
return alias;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Node dg(Node node, Class<?> clazz) {
|
||||||
|
if (Objects.isNull(node.getPIndex())) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
Node pNode = getByIndex(node.getPIndex());
|
||||||
|
if (pNode.getClazz() == clazz) {
|
||||||
|
return pNode;
|
||||||
|
}
|
||||||
|
return dg(pNode, clazz);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPrefixByClass(Class<?> clazz) {
|
||||||
|
Node node = getByClassFirst(clazz);
|
||||||
|
if (Objects.isNull(node)) {
|
||||||
|
return alias;
|
||||||
|
} else {
|
||||||
|
return node.hasAlias ? node.getAlias() : (node.getAlias() + StringPool.DOT + node.getIndex());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Node getByIndex(int index) {
|
private Node getByIndex(int index) {
|
||||||
return all.stream().filter(i -> i.getIndex() == index).findFirst().orElse(null);
|
return all.stream().filter(i -> i.getIndex() == index).findFirst().orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Node getByClassFirst(Class<?> clazz) {
|
||||||
|
return all.stream().filter(i -> i.getClazz() == clazz).findFirst().orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Node> getByClass(Class<?> clazz) {
|
||||||
|
return all.stream().filter(i -> i.getClazz() == clazz).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
this.all.clear();
|
||||||
|
this.child.clear();
|
||||||
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class Node {
|
public static class Node {
|
||||||
|
|
||||||
|
@ -6,17 +6,16 @@ import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
|||||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||||
import com.github.yulichang.config.ConfigProperties;
|
import com.github.yulichang.config.ConfigProperties;
|
||||||
import com.github.yulichang.toolkit.LambdaUtils;
|
import com.github.yulichang.toolkit.LambdaUtils;
|
||||||
|
import com.github.yulichang.toolkit.TableList;
|
||||||
import com.github.yulichang.toolkit.support.ColumnCache;
|
import com.github.yulichang.toolkit.support.ColumnCache;
|
||||||
import com.github.yulichang.wrapper.segments.Select;
|
import com.github.yulichang.wrapper.enums.PrefixEnum;
|
||||||
import com.github.yulichang.wrapper.segments.SelectCache;
|
import com.github.yulichang.wrapper.segments.SelectCache;
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import static java.util.stream.Collectors.joining;
|
import static java.util.stream.Collectors.joining;
|
||||||
|
|
||||||
@ -42,27 +41,22 @@ public abstract class MPJAbstractLambdaWrapper<T, Children extends MPJAbstractLa
|
|||||||
* 表序号
|
* 表序号
|
||||||
*/
|
*/
|
||||||
protected int tableIndex = 1;
|
protected int tableIndex = 1;
|
||||||
/**
|
|
||||||
* 关联的表
|
|
||||||
*/
|
|
||||||
protected TableList tableList;
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected <X> String columnToString(String index, int node, X column, boolean isJoin, Class<?> parent) {
|
protected <X> String columnToString(Integer index, X column, boolean isJoin, PrefixEnum prefixEnum) {
|
||||||
return columnToString(index, node, (SFunction<?, ?>) column, isJoin, parent);
|
return columnToString(index, (SFunction<?, ?>) column, isJoin, prefixEnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
protected final <X> String columnsToString(String index, int node, boolean isJoin, Class<?> parent, X... columns) {
|
protected final <X> String columnsToString(Integer index, boolean isJoin, PrefixEnum prefixEnum, X... columns) {
|
||||||
return Arrays.stream(columns).map(i -> columnToString(index, node, (SFunction<?, ?>) i, isJoin, parent)).collect(joining(StringPool.COMMA));
|
return Arrays.stream(columns).map(i -> columnToString(index, (SFunction<?, ?>) i, isJoin, prefixEnum)).collect(joining(StringPool.COMMA));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String columnToString(String index, int node, SFunction<?, ?> column, boolean isJoin, Class<?> parent) {
|
protected String columnToString(Integer index, SFunction<?, ?> column, boolean isJoin, PrefixEnum prefixEnum) {
|
||||||
Class<?> entityClass = LambdaUtils.getEntityClass(column);
|
Class<?> entityClass = LambdaUtils.getEntityClass(column);
|
||||||
return getDefault(index, node, entityClass, isJoin, parent) + StringPool.DOT +
|
return getDefault(index, entityClass, isJoin, prefixEnum) + StringPool.DOT + getCache(column).getTagColumn();
|
||||||
getCache(column).getTagColumn();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SelectCache getCache(SFunction<?, ?> fn) {
|
protected SelectCache getCache(SFunction<?, ?> fn) {
|
||||||
@ -74,183 +68,25 @@ public abstract class MPJAbstractLambdaWrapper<T, Children extends MPJAbstractLa
|
|||||||
/**
|
/**
|
||||||
* 返回前缀
|
* 返回前缀
|
||||||
*/
|
*/
|
||||||
protected String getDefault(String index, int node, Class<?> clazz, boolean isJoin, Class<?> parent) {
|
protected String getDefault(Integer index, Class<?> clazz, boolean isJoin, PrefixEnum prefixEnum) {
|
||||||
//外层where条件
|
if (prefixEnum == PrefixEnum.ON_FIRST) {
|
||||||
if (Objects.isNull(index)) {
|
return tableList.getPrefix(index, clazz, false);
|
||||||
if (!isJoin && Objects.equals(clazz, getEntityClass())) {
|
} else if (prefixEnum == PrefixEnum.ON_SECOND) {
|
||||||
return this.alias;
|
return isJoin ? tableList.getPrefixOther(index, clazz) : tableList.getPrefix(index, clazz, false);
|
||||||
}
|
} else if (prefixEnum == PrefixEnum.CD_FIRST) {
|
||||||
//正序
|
return tableList.getPrefix(index, clazz, false);
|
||||||
Table table = tableList.getPositive(clazz);
|
} else if (prefixEnum == PrefixEnum.CD_SECOND) {
|
||||||
return table.hasAlias ? table.alias : (table.alias + (Objects.isNull(table.index) ? StringPool.EMPTY : table.index));
|
return isJoin ? tableList.getPrefixOther(index, clazz) :
|
||||||
}
|
tableList.getPrefix(index, clazz, false);
|
||||||
Table table = tableList.get(clazz, index);
|
} else if (prefixEnum == PrefixEnum.CD_ON_FIRST) {
|
||||||
if (table.hasAlias) {
|
return tableList.getPrefix(index, clazz, false);
|
||||||
return table.alias;
|
} else if (prefixEnum == PrefixEnum.CD_ON_SECOND) {
|
||||||
}
|
return isJoin ? tableList.getPrefixOther(index, clazz) :
|
||||||
if (Objects.nonNull(table.getIndex())) {
|
tableList.getPrefix(index, clazz, false);
|
||||||
if (isJoin && (Objects.equals(clazz, getEntityClass()) || Objects.equals(parent, clazz))) {
|
|
||||||
if (node == -1) {
|
|
||||||
return table.alias;
|
|
||||||
} else if (node == 0) {
|
|
||||||
//除自己以外的倒序第一个
|
|
||||||
Table t = tableList.getOrElse(clazz, index);
|
|
||||||
if (Objects.isNull(t.getIndex())) {
|
|
||||||
return t.alias;
|
|
||||||
}
|
|
||||||
return t.alias + t.getIndex();
|
|
||||||
} else {
|
} else {
|
||||||
return table.alias + node;
|
return tableList.getAlias();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return table.alias + table.getIndex();
|
|
||||||
}
|
|
||||||
return table.alias;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String getDefaultSelect(String index, Class<?> clazz, Select s) {
|
|
||||||
if (s.isLabel()) {
|
|
||||||
if (Objects.nonNull(s.getIndex())) {
|
|
||||||
return s.getIndex();
|
|
||||||
} else {
|
|
||||||
Table table = tableList.get(s.getClazz());
|
|
||||||
return Objects.isNull(table.index) ? StringPool.EMPTY : table.index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//外层select
|
|
||||||
if (Objects.isNull(index)) {
|
|
||||||
if (Objects.equals(clazz, getEntityClass())) {
|
|
||||||
return StringPool.EMPTY;
|
|
||||||
}
|
|
||||||
//正序
|
|
||||||
Table table = tableList.getPositive(clazz);
|
|
||||||
return Objects.isNull(table.index) ? StringPool.EMPTY : table.index;
|
|
||||||
}
|
|
||||||
Table table = tableList.get(clazz, index);
|
|
||||||
if (Objects.nonNull(table.getIndex())) {
|
|
||||||
return table.getIndex();
|
|
||||||
}
|
|
||||||
return StringPool.EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class TableList {
|
|
||||||
|
|
||||||
private final Table DEFAULT_TABLE;
|
|
||||||
|
|
||||||
public TableList(Class<?> clazz, String index, String alias) {
|
|
||||||
DEFAULT_TABLE = new Table(clazz, index, false, alias);
|
|
||||||
}
|
|
||||||
|
|
||||||
private final List<Table> list = new ArrayList<>();
|
|
||||||
|
|
||||||
public void add(Class<?> clazz, String index, boolean hasAlias, String alias) {
|
|
||||||
this.list.add(new Table(clazz, index, hasAlias, alias));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Table get(Class<?> clazz) {
|
|
||||||
if (list.isEmpty()) {
|
|
||||||
return DEFAULT_TABLE;
|
|
||||||
}
|
|
||||||
for (int i = list.size() - 1; i >= 0; i--) {
|
|
||||||
Table t = list.get(i);
|
|
||||||
if (clazz == t.clazz) {
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return DEFAULT_TABLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Table get(Class<?> clazz, String index) {
|
|
||||||
if (Objects.isNull(index)) {
|
|
||||||
return get(clazz);
|
|
||||||
}
|
|
||||||
if (list.isEmpty()) {
|
|
||||||
return DEFAULT_TABLE;
|
|
||||||
}
|
|
||||||
//倒序
|
|
||||||
for (int i = list.size() - 1; i >= 0; i--) {
|
|
||||||
Table t = list.get(i);
|
|
||||||
if (clazz == t.clazz && Objects.equals(index, t.getIndex())) {
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return get(clazz);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public Table getPositive(Class<?> clazz, String index) {
|
|
||||||
if (Objects.isNull(index)) {
|
|
||||||
return get(clazz);
|
|
||||||
}
|
|
||||||
if (list.isEmpty()) {
|
|
||||||
return DEFAULT_TABLE;
|
|
||||||
}
|
|
||||||
for (Table t : list) {
|
|
||||||
if (clazz == t.clazz && Objects.equals(index, t.getIndex())) {
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return getPositive(clazz);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Table getPositive(Class<?> clazz) {
|
|
||||||
if (list.isEmpty()) {
|
|
||||||
return DEFAULT_TABLE;
|
|
||||||
}
|
|
||||||
for (Table t : list) {
|
|
||||||
if (clazz == t.clazz) {
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return DEFAULT_TABLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Stream<Table> stream() {
|
|
||||||
return list.stream();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clear() {
|
|
||||||
list.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEmpty() {
|
|
||||||
return list.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Table getOrElse(Class<?> clazz, String index) {
|
|
||||||
if (Objects.isNull(index)) {
|
|
||||||
return get(clazz);
|
|
||||||
}
|
|
||||||
//倒序
|
|
||||||
for (int i = list.size() - 1; i >= 0; i--) {
|
|
||||||
Table t = list.get(i);
|
|
||||||
if (clazz == t.clazz) {
|
|
||||||
if (Objects.equals(index, t.getIndex())) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (Integer.parseInt(t.getIndex()) < Integer.parseInt(index)) {
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return DEFAULT_TABLE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode
|
|
||||||
@AllArgsConstructor
|
|
||||||
public static class Table {
|
|
||||||
private final Class<?> clazz;
|
|
||||||
|
|
||||||
private final String index;
|
|
||||||
|
|
||||||
private boolean hasAlias;
|
|
||||||
|
|
||||||
private final String alias;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 必要的初始化
|
* 必要的初始化
|
||||||
@ -262,7 +98,7 @@ public abstract class MPJAbstractLambdaWrapper<T, Children extends MPJAbstractLa
|
|||||||
lastSql = SharedString.emptyString();
|
lastSql = SharedString.emptyString();
|
||||||
sqlComment = SharedString.emptyString();
|
sqlComment = SharedString.emptyString();
|
||||||
sqlFirst = SharedString.emptyString();
|
sqlFirst = SharedString.emptyString();
|
||||||
node = ROOT_NODE;
|
tableList = new TableList();
|
||||||
tableList = new TableList(getEntityClass(), null, alias);
|
tableList.setAlias(alias);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,11 @@ import com.baomidou.mybatisplus.core.toolkit.*;
|
|||||||
import com.baomidou.mybatisplus.core.toolkit.sql.SqlUtils;
|
import com.baomidou.mybatisplus.core.toolkit.sql.SqlUtils;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.sql.StringEscape;
|
import com.baomidou.mybatisplus.core.toolkit.sql.StringEscape;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||||
|
import com.github.yulichang.toolkit.LambdaUtils;
|
||||||
|
import com.github.yulichang.toolkit.TableList;
|
||||||
import com.github.yulichang.toolkit.sql.SqlScriptUtils;
|
import com.github.yulichang.toolkit.sql.SqlScriptUtils;
|
||||||
|
import com.github.yulichang.wrapper.enums.PrefixEnum;
|
||||||
import com.github.yulichang.wrapper.interfaces.*;
|
import com.github.yulichang.wrapper.interfaces.*;
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -36,8 +38,6 @@ public abstract class MPJAbstractWrapper<T, Children extends MPJAbstractWrapper<
|
|||||||
implements Compare<Children>, Nested<Children, Children>, Join<Children>, Func<Children>, OnCompare<Children>,
|
implements Compare<Children>, Nested<Children, Children>, Join<Children>, Func<Children>, OnCompare<Children>,
|
||||||
CompareStr<Children, String>, FuncStr<Children, String> {
|
CompareStr<Children, String>, FuncStr<Children, String> {
|
||||||
|
|
||||||
protected static final Node ROOT_NODE = new Node(null, 0, null);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 占位符
|
* 占位符
|
||||||
*/
|
*/
|
||||||
@ -46,7 +46,7 @@ public abstract class MPJAbstractWrapper<T, Children extends MPJAbstractWrapper<
|
|||||||
* 表别名
|
* 表别名
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
protected String index;
|
protected Integer index;
|
||||||
/**
|
/**
|
||||||
* 必要度量
|
* 必要度量
|
||||||
*/
|
*/
|
||||||
@ -85,11 +85,19 @@ public abstract class MPJAbstractWrapper<T, Children extends MPJAbstractWrapper<
|
|||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
protected Class<?> joinClass;
|
protected Class<?> joinClass;
|
||||||
|
/**
|
||||||
|
* 主表wrapper
|
||||||
|
*/
|
||||||
|
protected boolean isMain = true;
|
||||||
|
/**
|
||||||
|
* 是否是OnWrapper
|
||||||
|
*/
|
||||||
|
protected boolean isNo = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 寻路
|
* 关联的表
|
||||||
*/
|
*/
|
||||||
protected Node node;
|
protected TableList tableList;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T getEntity() {
|
public T getEntity() {
|
||||||
@ -113,6 +121,9 @@ public abstract class MPJAbstractWrapper<T, Children extends MPJAbstractWrapper<
|
|||||||
onWrappers.forEach(i -> i.setEntityClass(entityClass));
|
onWrappers.forEach(i -> i.setEntityClass(entityClass));
|
||||||
this.entityClass = entityClass;
|
this.entityClass = entityClass;
|
||||||
}
|
}
|
||||||
|
if (tableList != null) {
|
||||||
|
tableList.setRootClass(entityClass);
|
||||||
|
}
|
||||||
return typedThis;
|
return typedThis;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,7 +360,7 @@ public abstract class MPJAbstractWrapper<T, Children extends MPJAbstractWrapper<
|
|||||||
public <R> Children groupBy(boolean condition, List<SFunction<R, ?>> columns) {
|
public <R> Children groupBy(boolean condition, List<SFunction<R, ?>> columns) {
|
||||||
return maybeDo(condition, () -> {
|
return maybeDo(condition, () -> {
|
||||||
if (CollectionUtils.isNotEmpty(columns)) {
|
if (CollectionUtils.isNotEmpty(columns)) {
|
||||||
String one = (StringPool.COMMA + columnsToString(index, getByClass(node, joinClass), false, parentClass(node), columns));
|
String one = (StringPool.COMMA + columnsToString(index, false, isNo ? PrefixEnum.ON_FIRST : PrefixEnum.CD_FIRST, columns));
|
||||||
final String finalOne = one;
|
final String finalOne = one;
|
||||||
appendSqlSegments(GROUP_BY, () -> finalOne);
|
appendSqlSegments(GROUP_BY, () -> finalOne);
|
||||||
}
|
}
|
||||||
@ -359,9 +370,9 @@ public abstract class MPJAbstractWrapper<T, Children extends MPJAbstractWrapper<
|
|||||||
@Override
|
@Override
|
||||||
public <X> Children groupBy(boolean condition, SFunction<X, ?> column, SFunction<X, ?>... columns) {
|
public <X> Children groupBy(boolean condition, SFunction<X, ?> column, SFunction<X, ?>... columns) {
|
||||||
return maybeDo(condition, () -> {
|
return maybeDo(condition, () -> {
|
||||||
String one = columnToString(index, getByClass(node, joinClass), column, false, parentClass(node));
|
String one = columnToString(index, column, false, isNo ? PrefixEnum.ON_FIRST : PrefixEnum.CD_FIRST);
|
||||||
if (ArrayUtils.isNotEmpty(columns)) {
|
if (ArrayUtils.isNotEmpty(columns)) {
|
||||||
one += (StringPool.COMMA + columnsToString(index, getByClass(node, joinClass), false, parentClass(node), columns));
|
one += (StringPool.COMMA + columnsToString(index, false, isNo ? PrefixEnum.ON_FIRST : PrefixEnum.CD_FIRST, columns));
|
||||||
}
|
}
|
||||||
final String finalOne = one;
|
final String finalOne = one;
|
||||||
appendSqlSegments(GROUP_BY, () -> finalOne);
|
appendSqlSegments(GROUP_BY, () -> finalOne);
|
||||||
@ -467,8 +478,13 @@ public abstract class MPJAbstractWrapper<T, Children extends MPJAbstractWrapper<
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected <X, S> Children addCondition(boolean condition, SFunction<X, ?> column, SqlKeyword sqlKeyword, SFunction<S, ?> val) {
|
protected <X, S> Children addCondition(boolean condition, SFunction<X, ?> column, SqlKeyword sqlKeyword, SFunction<S, ?> val) {
|
||||||
|
Class<X> c = LambdaUtils.getEntityClass(column);
|
||||||
|
Class<S> v = LambdaUtils.getEntityClass(val);
|
||||||
return maybeDo(condition, () -> appendSqlSegments(columnToSqlSegment(index, column, false), sqlKeyword,
|
return maybeDo(condition, () -> appendSqlSegments(columnToSqlSegment(index, column, false), sqlKeyword,
|
||||||
columnToSqlSegment(index, val, true)));
|
isNo ?
|
||||||
|
columnToSqlSegmentS(index, val, v == c && v == joinClass) :
|
||||||
|
columnToSqlSegmentS(index, val, v == c)
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Children addCondition(boolean condition, String column, SqlKeyword sqlKeyword, Object val) {
|
protected Children addCondition(boolean condition, String column, SqlKeyword sqlKeyword, Object val) {
|
||||||
@ -643,8 +659,24 @@ public abstract class MPJAbstractWrapper<T, Children extends MPJAbstractWrapper<
|
|||||||
/**
|
/**
|
||||||
* 获取 columnName
|
* 获取 columnName
|
||||||
*/
|
*/
|
||||||
protected final <X> ISqlSegment columnToSqlSegment(String index, SFunction<X, ?> column, boolean isJoin) {
|
protected final <X> ISqlSegment columnToSqlSegment(Integer index, SFunction<X, ?> column, boolean isJoin) {
|
||||||
return () -> columnToString(index, getByClass(node, joinClass), column, isJoin, parentClass(node));
|
PrefixEnum prefixEnum;
|
||||||
|
if (isMain) {
|
||||||
|
prefixEnum = isNo ? PrefixEnum.ON_FIRST /* 理论上不可能有这种情况 */ : PrefixEnum.CD_FIRST;
|
||||||
|
} else {
|
||||||
|
prefixEnum = isNo ? PrefixEnum.ON_FIRST : PrefixEnum.CD_ON_FIRST;
|
||||||
|
}
|
||||||
|
return () -> columnToString(index, column, isJoin, isNo ? PrefixEnum.ON_FIRST : PrefixEnum.CD_FIRST);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final <X> ISqlSegment columnToSqlSegmentS(Integer index, SFunction<X, ?> column, boolean isJoin) {
|
||||||
|
PrefixEnum prefixEnum;
|
||||||
|
if (isMain) {
|
||||||
|
prefixEnum = isNo ? PrefixEnum.ON_SECOND /* 理论上不可能有这种情况 */ : PrefixEnum.CD_SECOND;
|
||||||
|
} else {
|
||||||
|
prefixEnum = isNo ? PrefixEnum.ON_SECOND : PrefixEnum.CD_ON_SECOND;
|
||||||
|
}
|
||||||
|
return () -> columnToString(index, column, isJoin, prefixEnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final <X> ISqlSegment columnToSqlSegment(String column) {
|
protected final <X> ISqlSegment columnToSqlSegment(String column) {
|
||||||
@ -654,7 +686,7 @@ public abstract class MPJAbstractWrapper<T, Children extends MPJAbstractWrapper<
|
|||||||
/**
|
/**
|
||||||
* 获取 columnName
|
* 获取 columnName
|
||||||
*/
|
*/
|
||||||
protected <X> String columnToString(String index, int node, X column, boolean isJoin, Class<?> parent) {
|
protected <X> String columnToString(Integer index, X column, boolean isJoin, PrefixEnum prefixEnum) {
|
||||||
return (String) column;
|
return (String) column;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -676,8 +708,8 @@ public abstract class MPJAbstractWrapper<T, Children extends MPJAbstractWrapper<
|
|||||||
*
|
*
|
||||||
* @param columns 多字段
|
* @param columns 多字段
|
||||||
*/
|
*/
|
||||||
protected <X> String columnsToString(String index, int node, boolean isJoin, Class<?> parent, X... columns) {
|
protected <X> String columnsToString(Integer index, boolean isJoin, PrefixEnum prefixEnum, X... columns) {
|
||||||
return Arrays.stream(columns).map(i -> this.columnToString(index, node, i, isJoin, parent)).collect(joining(StringPool.COMMA));
|
return Arrays.stream(columns).map(i -> this.columnToString(index, i, isJoin, prefixEnum)).collect(joining(StringPool.COMMA));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -727,46 +759,6 @@ public abstract class MPJAbstractWrapper<T, Children extends MPJAbstractWrapper<
|
|||||||
return addCondition(condition, column, LE, val);
|
return addCondition(condition, column, LE, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter
|
|
||||||
@AllArgsConstructor
|
|
||||||
public static class Node {
|
|
||||||
|
|
||||||
private Class<?> clazz;
|
|
||||||
|
|
||||||
private int index;
|
|
||||||
|
|
||||||
private Node parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private int getByClass(Node node, Class<?> joinClass) {
|
|
||||||
if (joinClass == null) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (node.parent != null) {
|
|
||||||
return dg(node.parent, joinClass);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Class<?> parentClass(Node node) {
|
|
||||||
if (node == null || node.parent == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return node.parent.clazz;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int dg(Node node, Class<?> joinClass) {
|
|
||||||
|
|
||||||
if (node.clazz != null && node.clazz == joinClass) {
|
|
||||||
return node.index;
|
|
||||||
}
|
|
||||||
if (node.parent == null) {
|
|
||||||
return joinClass == getEntityClass() ? -1 : 0;
|
|
||||||
}
|
|
||||||
return getByClass(node.parent, joinClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ****************************************** **/
|
/* ****************************************** **/
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,10 +6,8 @@ import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
|||||||
import com.baomidou.mybatisplus.core.toolkit.*;
|
import com.baomidou.mybatisplus.core.toolkit.*;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||||
import com.github.yulichang.config.ConfigProperties;
|
import com.github.yulichang.config.ConfigProperties;
|
||||||
import com.github.yulichang.toolkit.Constant;
|
|
||||||
import com.github.yulichang.toolkit.LambdaUtils;
|
import com.github.yulichang.toolkit.LambdaUtils;
|
||||||
import com.github.yulichang.toolkit.LogicInfoUtils;
|
import com.github.yulichang.toolkit.*;
|
||||||
import com.github.yulichang.toolkit.TableHelper;
|
|
||||||
import com.github.yulichang.toolkit.support.ColumnCache;
|
import com.github.yulichang.toolkit.support.ColumnCache;
|
||||||
import com.github.yulichang.wrapper.interfaces.Query;
|
import com.github.yulichang.wrapper.interfaces.Query;
|
||||||
import com.github.yulichang.wrapper.interfaces.QueryJoin;
|
import com.github.yulichang.wrapper.interfaces.QueryJoin;
|
||||||
@ -52,6 +50,7 @@ public class MPJLambdaWrapper<T> extends MPJAbstractLambdaWrapper<T, MPJLambdaWr
|
|||||||
/**
|
/**
|
||||||
* 是否有表别名
|
* 是否有表别名
|
||||||
*/
|
*/
|
||||||
|
@Getter
|
||||||
private boolean hasAlias;
|
private boolean hasAlias;
|
||||||
/**
|
/**
|
||||||
* 查询字段 sql
|
* 查询字段 sql
|
||||||
@ -88,6 +87,7 @@ public class MPJLambdaWrapper<T> extends MPJAbstractLambdaWrapper<T, MPJLambdaWr
|
|||||||
public MPJLambdaWrapper(Class<T> clazz) {
|
public MPJLambdaWrapper(Class<T> clazz) {
|
||||||
super.initNeed();
|
super.initNeed();
|
||||||
setEntityClass(clazz);
|
setEntityClass(clazz);
|
||||||
|
tableList.setRootClass(clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -96,6 +96,7 @@ public class MPJLambdaWrapper<T> extends MPJAbstractLambdaWrapper<T, MPJLambdaWr
|
|||||||
public MPJLambdaWrapper(String alias) {
|
public MPJLambdaWrapper(String alias) {
|
||||||
this.alias = alias;
|
this.alias = alias;
|
||||||
super.initNeed();
|
super.initNeed();
|
||||||
|
tableList.setAlias(alias);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -105,6 +106,8 @@ public class MPJLambdaWrapper<T> extends MPJAbstractLambdaWrapper<T, MPJLambdaWr
|
|||||||
this.alias = alias;
|
this.alias = alias;
|
||||||
setEntityClass(clazz);
|
setEntityClass(clazz);
|
||||||
super.initNeed();
|
super.initNeed();
|
||||||
|
tableList.setAlias(alias);
|
||||||
|
tableList.setRootClass(clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -114,7 +117,7 @@ public class MPJLambdaWrapper<T> extends MPJAbstractLambdaWrapper<T, MPJLambdaWr
|
|||||||
MPJLambdaWrapper(T entity, Class<T> entityClass, SharedString sqlSelect, AtomicInteger paramNameSeq,
|
MPJLambdaWrapper(T entity, Class<T> entityClass, SharedString sqlSelect, AtomicInteger paramNameSeq,
|
||||||
Map<String, Object> paramNameValuePairs, MergeSegments mergeSegments,
|
Map<String, Object> paramNameValuePairs, MergeSegments mergeSegments,
|
||||||
SharedString lastSql, SharedString sqlComment, SharedString sqlFirst,
|
SharedString lastSql, SharedString sqlComment, SharedString sqlFirst,
|
||||||
TableList tableList, String index, String keyWord, Class<?> joinClass, Node node) {
|
TableList tableList, Integer index, String keyWord, Class<?> joinClass) {
|
||||||
super.setEntity(entity);
|
super.setEntity(entity);
|
||||||
super.setEntityClass(entityClass);
|
super.setEntityClass(entityClass);
|
||||||
this.paramNameSeq = paramNameSeq;
|
this.paramNameSeq = paramNameSeq;
|
||||||
@ -128,7 +131,6 @@ public class MPJLambdaWrapper<T> extends MPJAbstractLambdaWrapper<T, MPJLambdaWr
|
|||||||
this.index = index;
|
this.index = index;
|
||||||
this.keyWord = keyWord;
|
this.keyWord = keyWord;
|
||||||
this.joinClass = joinClass;
|
this.joinClass = joinClass;
|
||||||
this.node = node;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -172,7 +174,7 @@ public class MPJLambdaWrapper<T> extends MPJAbstractLambdaWrapper<T, MPJLambdaWr
|
|||||||
Map<String, SelectCache> cacheMap = ColumnCache.getMapField(aClass);
|
Map<String, SelectCache> cacheMap = ColumnCache.getMapField(aClass);
|
||||||
for (SFunction<E, ?> s : columns) {
|
for (SFunction<E, ?> s : columns) {
|
||||||
SelectCache cache = cacheMap.get(LambdaUtils.getName(s));
|
SelectCache cache = cacheMap.get(LambdaUtils.getName(s));
|
||||||
getSelectColum().add(new SelectNormal(cache, index));
|
getSelectColum().add(new SelectNormal(cache, index, hasAlias, alias));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return typedThis;
|
return typedThis;
|
||||||
@ -188,17 +190,17 @@ public class MPJLambdaWrapper<T> extends MPJAbstractLambdaWrapper<T, MPJLambdaWr
|
|||||||
if (i.isStr()) {
|
if (i.isStr()) {
|
||||||
return i.getColumn();
|
return i.getColumn();
|
||||||
}
|
}
|
||||||
Table t = tableList.get(i.getClazz());
|
String prefix;
|
||||||
String str;
|
if (i.isLabel()) {
|
||||||
if (t.isHasAlias()) {
|
if (i.isHasTableAlias()) {
|
||||||
str = t.getAlias() + StringPool.DOT + i.getColumn();
|
prefix = i.getTableAlias();
|
||||||
} else {
|
} else {
|
||||||
if (i.isLabel() && Objects.nonNull(i.getIndex())) {
|
prefix = tableList.getPrefix(i.getIndex(), i.getClazz(), true);
|
||||||
str = i.getIndex() + StringPool.DOT + i.getColumn();
|
}
|
||||||
} else {
|
} else {
|
||||||
str = t.getAlias() + getDefaultSelect(i.getIndex(), i.getClazz(), i) + StringPool.DOT + i.getColumn();
|
prefix = tableList.getPrefix(i.getIndex(), i.getClazz(), false);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
String str = prefix + StringPool.DOT + i.getColumn();
|
||||||
if (i.isFunc()) {
|
if (i.isFunc()) {
|
||||||
SFunction<?, ?>[] args = i.getArgs();
|
SFunction<?, ?>[] args = i.getArgs();
|
||||||
if (Objects.isNull(args) || args.length == 0) {
|
if (Objects.isNull(args) || args.length == 0) {
|
||||||
@ -206,11 +208,10 @@ public class MPJLambdaWrapper<T> extends MPJAbstractLambdaWrapper<T, MPJLambdaWr
|
|||||||
} else {
|
} else {
|
||||||
return String.format(i.getFunc().getSql(), Arrays.stream(args).map(arg -> {
|
return String.format(i.getFunc().getSql(), Arrays.stream(args).map(arg -> {
|
||||||
Class<?> entityClass = LambdaUtils.getEntityClass(arg);
|
Class<?> entityClass = LambdaUtils.getEntityClass(arg);
|
||||||
Table table = tableList.getPositive(entityClass);
|
String prefixByClass = tableList.getPrefixByClass(entityClass);
|
||||||
Assert.notNull(table, "table not find by class <%s>", entityClass.getSimpleName());
|
|
||||||
Map<String, SelectCache> mapField = ColumnCache.getMapField(entityClass);
|
Map<String, SelectCache> mapField = ColumnCache.getMapField(entityClass);
|
||||||
SelectCache cache = mapField.get(LambdaUtils.getName(arg));
|
SelectCache cache = mapField.get(LambdaUtils.getName(arg));
|
||||||
return tableList.get(cache.getClazz()).getAlias() + (Objects.isNull(table.getIndex()) ? StringPool.EMPTY : table.getIndex()) + StringPool.DOT + cache.getColumn();
|
return prefixByClass + StringPool.DOT + cache.getColumn();
|
||||||
}).toArray()) + Constant.AS + i.getAlias();
|
}).toArray()) + Constant.AS + i.getAlias();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -238,7 +239,7 @@ public class MPJLambdaWrapper<T> extends MPJAbstractLambdaWrapper<T, MPJLambdaWr
|
|||||||
.append(StringPool.SPACE)
|
.append(StringPool.SPACE)
|
||||||
.append(tableName)
|
.append(tableName)
|
||||||
.append(StringPool.SPACE)
|
.append(StringPool.SPACE)
|
||||||
.append(wrapper.hasAlias ? wrapper.alias : (wrapper.alias + (tableList.get(wrapper.getJoinClass(), wrapper.getIndex()).getIndex())))
|
.append(wrapper.hasAlias ? wrapper.alias : (wrapper.alias + wrapper.getIndex()))
|
||||||
.append(Constant.ON)
|
.append(Constant.ON)
|
||||||
.append(wrapper.getExpression().getNormal().getSqlSegment());
|
.append(wrapper.getExpression().getNormal().getSqlSegment());
|
||||||
} else {
|
} else {
|
||||||
@ -269,13 +270,13 @@ public class MPJLambdaWrapper<T> extends MPJAbstractLambdaWrapper<T, MPJLambdaWr
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected MPJLambdaWrapper<T> instance() {
|
protected MPJLambdaWrapper<T> instance() {
|
||||||
return instance(index, null, null, this.node);
|
return instance(index, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected MPJLambdaWrapper<T> instance(String index, String keyWord, Class<?> joinClass, Node node) {
|
protected MPJLambdaWrapper<T> instance(Integer index, String keyWord, Class<?> joinClass) {
|
||||||
return new MPJLambdaWrapper<>(getEntity(), getEntityClass(), null, paramNameSeq, paramNameValuePairs,
|
return new MPJLambdaWrapper<>(getEntity(), getEntityClass(), null, paramNameSeq, paramNameValuePairs,
|
||||||
new MergeSegments(), SharedString.emptyString(), SharedString.emptyString(), SharedString.emptyString(),
|
new MergeSegments(), SharedString.emptyString(), SharedString.emptyString(), SharedString.emptyString(),
|
||||||
this.tableList, index, keyWord, joinClass, node);
|
this.tableList, index, keyWord, joinClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -322,10 +323,10 @@ public class MPJLambdaWrapper<T> extends MPJAbstractLambdaWrapper<T, MPJLambdaWr
|
|||||||
*/
|
*/
|
||||||
public String getSubLogicSql() {
|
public String getSubLogicSql() {
|
||||||
if (subLogicSql) {
|
if (subLogicSql) {
|
||||||
if (tableList.isEmpty()) {
|
if (tableList.getAll().isEmpty()) {
|
||||||
return StringPool.EMPTY;
|
return StringPool.EMPTY;
|
||||||
}
|
}
|
||||||
return tableList.stream().map(t -> LogicInfoUtils.getLogicInfo(t.getIndex(),
|
return tableList.getAll().stream().map(t -> LogicInfoUtils.getLogicInfo(t.getIndex(),
|
||||||
t.getClazz(), t.isHasAlias(), t.getAlias())).collect(Collectors.joining(StringPool.SPACE));
|
t.getClazz(), t.isHasAlias(), t.getAlias())).collect(Collectors.joining(StringPool.SPACE));
|
||||||
}
|
}
|
||||||
return StringPool.EMPTY;
|
return StringPool.EMPTY;
|
||||||
@ -343,24 +344,26 @@ public class MPJLambdaWrapper<T> extends MPJAbstractLambdaWrapper<T, MPJLambdaWr
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public <R> MPJLambdaWrapper<T> join(String keyWord, Class<R> clazz, String tableAlias, BiConsumer<MPJAbstractLambdaWrapper<T, ?>, MPJLambdaWrapper<T>> consumer) {
|
public <R> MPJLambdaWrapper<T> join(String keyWord, Class<R> clazz, String tableAlias, BiConsumer<MPJAbstractLambdaWrapper<T, ?>, MPJLambdaWrapper<T>> consumer) {
|
||||||
String oldIndex = this.getIndex();
|
Integer oldIndex = this.getIndex();
|
||||||
String newIndex = String.valueOf(tableIndex);
|
int newIndex = tableIndex;
|
||||||
Node n = Objects.isNull(oldIndex) ? new Node(clazz, tableIndex, ROOT_NODE) : new Node(clazz, tableIndex, this.node);
|
MPJLambdaWrapper<T> instance = instance(newIndex, keyWord, clazz);
|
||||||
MPJLambdaWrapper<T> instance = instance(newIndex, keyWord, clazz, n);
|
instance.isNo = true;
|
||||||
this.node = n;
|
|
||||||
onWrappers.add(instance);
|
onWrappers.add(instance);
|
||||||
if (StringUtils.isBlank(tableAlias)) {
|
if (StringUtils.isBlank(tableAlias)) {
|
||||||
tableList.add(clazz, newIndex, false, ConfigProperties.tableAlias);
|
tableList.put(oldIndex, clazz, false, ConfigProperties.tableAlias, newIndex);
|
||||||
instance.alias = ConfigProperties.tableAlias;
|
instance.alias = ConfigProperties.tableAlias;
|
||||||
instance.hasAlias = false;
|
instance.hasAlias = false;
|
||||||
tableIndex++;
|
|
||||||
} else {
|
} else {
|
||||||
tableList.add(clazz, null, true, tableAlias);
|
tableList.put(oldIndex, clazz, true, tableAlias, newIndex);
|
||||||
instance.alias = tableAlias;
|
instance.alias = tableAlias;
|
||||||
instance.hasAlias = true;
|
instance.hasAlias = true;
|
||||||
}
|
}
|
||||||
|
tableIndex++;
|
||||||
this.index = newIndex;
|
this.index = newIndex;
|
||||||
|
boolean isM = this.isMain;
|
||||||
|
this.isMain = false;
|
||||||
consumer.accept(instance, typedThis);
|
consumer.accept(instance, typedThis);
|
||||||
|
this.isMain = isM;
|
||||||
this.index = oldIndex;
|
this.index = oldIndex;
|
||||||
return typedThis;
|
return typedThis;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
package com.github.yulichang.wrapper.enums;
|
||||||
|
|
||||||
|
public enum PrefixEnum {
|
||||||
|
SELECT, ON_FIRST, ON_SECOND, CD_ON_FIRST, CD_ON_SECOND, CD_FIRST, CD_SECOND
|
||||||
|
}
|
@ -35,7 +35,11 @@ public interface Query<Children> extends Serializable {
|
|||||||
|
|
||||||
Children getChildren();
|
Children getChildren();
|
||||||
|
|
||||||
String getIndex();
|
Integer getIndex();
|
||||||
|
|
||||||
|
boolean isHasAlias();
|
||||||
|
|
||||||
|
String getAlias();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,7 +58,7 @@ public interface Query<Children> extends Serializable {
|
|||||||
Assert.notNull(info, "table not find by class <%s>", entityClass.getSimpleName());
|
Assert.notNull(info, "table not find by class <%s>", entityClass.getSimpleName());
|
||||||
Map<String, SelectCache> cacheMap = ColumnCache.getMapField(entityClass);
|
Map<String, SelectCache> cacheMap = ColumnCache.getMapField(entityClass);
|
||||||
info.getFieldList().stream().filter(predicate).collect(Collectors.toList()).forEach(
|
info.getFieldList().stream().filter(predicate).collect(Collectors.toList()).forEach(
|
||||||
i -> getSelectColum().add(new SelectNormal(cacheMap.get(i.getProperty()), getIndex())));
|
i -> getSelectColum().add(new SelectNormal(cacheMap.get(i.getProperty()), getIndex(), isHasAlias(), getAlias())));
|
||||||
return getChildren();
|
return getChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +72,7 @@ public interface Query<Children> extends Serializable {
|
|||||||
* @param columns 列
|
* @param columns 列
|
||||||
*/
|
*/
|
||||||
default Children select(String... columns) {
|
default Children select(String... columns) {
|
||||||
getSelectColum().addAll(Arrays.stream(columns).map(SelectString::new).collect(Collectors.toList()));
|
getSelectColum().addAll(Arrays.stream(columns).map(i -> new SelectString(i, isHasAlias(), getAlias())).collect(Collectors.toList()));
|
||||||
return getChildren();
|
return getChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,7 +82,7 @@ public interface Query<Children> extends Serializable {
|
|||||||
* @param column 列
|
* @param column 列
|
||||||
*/
|
*/
|
||||||
default <E> Children select(String column, SFunction<E, ?> alias) {
|
default <E> Children select(String column, SFunction<E, ?> alias) {
|
||||||
getSelectColum().add(new SelectString(column + Constants.AS + LambdaUtils.getName(alias)));
|
getSelectColum().add(new SelectString(column + Constants.AS + LambdaUtils.getName(alias), isHasAlias(), getAlias()));
|
||||||
return getChildren();
|
return getChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +94,9 @@ public interface Query<Children> extends Serializable {
|
|||||||
default <E> Children select(String index, SFunction<E, ?> column, SFunction<E, ?> alias) {
|
default <E> Children select(String index, SFunction<E, ?> column, SFunction<E, ?> alias) {
|
||||||
Map<String, SelectCache> cacheMap = ColumnCache.getMapField(LambdaUtils.getEntityClass(column));
|
Map<String, SelectCache> cacheMap = ColumnCache.getMapField(LambdaUtils.getEntityClass(column));
|
||||||
SelectCache cache = cacheMap.get(LambdaUtils.getName(column));
|
SelectCache cache = cacheMap.get(LambdaUtils.getName(column));
|
||||||
getSelectColum().add(new SelectString(index + Constants.DOT + cache.getColumn() + Constants.AS + LambdaUtils.getName(alias)));
|
getSelectColum().add(new SelectString(
|
||||||
|
index + Constants.DOT + cache.getColumn() + Constants.AS + LambdaUtils.getName(alias),
|
||||||
|
isHasAlias(), getAlias()));
|
||||||
return getChildren();
|
return getChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +115,7 @@ public interface Query<Children> extends Serializable {
|
|||||||
Map<String, Field> fieldMap = MPJReflectionKit.getFieldMap(tag);
|
Map<String, Field> fieldMap = MPJReflectionKit.getFieldMap(tag);
|
||||||
for (SelectCache cache : normalList) {
|
for (SelectCache cache : normalList) {
|
||||||
if (fieldMap.containsKey(cache.getColumProperty())) {
|
if (fieldMap.containsKey(cache.getColumProperty())) {
|
||||||
getSelectColum().add(new SelectNormal(cache, getIndex()));
|
getSelectColum().add(new SelectNormal(cache, getIndex(), isHasAlias(), getAlias()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return getChildren();
|
return getChildren();
|
||||||
@ -128,8 +134,7 @@ public interface Query<Children> extends Serializable {
|
|||||||
default <S> Children selectAs(SFunction<S, ?> column, String alias) {
|
default <S> Children selectAs(SFunction<S, ?> column, String alias) {
|
||||||
Class<?> aClass = LambdaUtils.getEntityClass(column);
|
Class<?> aClass = LambdaUtils.getEntityClass(column);
|
||||||
Map<String, SelectCache> cacheMap = ColumnCache.getMapField(aClass);
|
Map<String, SelectCache> cacheMap = ColumnCache.getMapField(aClass);
|
||||||
String index = getIndex();
|
getSelectColum().add(new SelectAlias(cacheMap.get(LambdaUtils.getName(column)), getIndex(), alias, isHasAlias(), getAlias()));
|
||||||
getSelectColum().add(new SelectAlias(cacheMap.get(LambdaUtils.getName(column)), getIndex(), alias));
|
|
||||||
return getChildren();
|
return getChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +144,7 @@ public interface Query<Children> extends Serializable {
|
|||||||
*/
|
*/
|
||||||
default Children selectAll(Class<?> clazz) {
|
default Children selectAll(Class<?> clazz) {
|
||||||
getSelectColum().addAll(ColumnCache.getListField(clazz).stream().map(i ->
|
getSelectColum().addAll(ColumnCache.getListField(clazz).stream().map(i ->
|
||||||
new SelectNormal(i, getIndex())).collect(Collectors.toList()));
|
new SelectNormal(i, getIndex(), isHasAlias(), getAlias())).collect(Collectors.toList()));
|
||||||
return getChildren();
|
return getChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,14 +166,14 @@ public interface Query<Children> extends Serializable {
|
|||||||
* @param alias 别名
|
* @param alias 别名
|
||||||
*/
|
*/
|
||||||
default Children selectFunc(BaseFuncEnum funcEnum, Object column, String alias) {
|
default Children selectFunc(BaseFuncEnum funcEnum, Object column, String alias) {
|
||||||
getSelectColum().add(new SelectFunc(alias, getIndex(), funcEnum, column.toString()));
|
getSelectColum().add(new SelectFunc(alias, getIndex(), funcEnum, column.toString(), isHasAlias(), getAlias()));
|
||||||
return getChildren();
|
return getChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
default <S> Children selectFunc(BaseFuncEnum funcEnum, SFunction<S, ?> column, String alias) {
|
default <S> Children selectFunc(BaseFuncEnum funcEnum, SFunction<S, ?> column, String alias) {
|
||||||
Class<?> aClass = LambdaUtils.getEntityClass(column);
|
Class<?> aClass = LambdaUtils.getEntityClass(column);
|
||||||
Map<String, SelectCache> cacheMap = ColumnCache.getMapField(aClass);
|
Map<String, SelectCache> cacheMap = ColumnCache.getMapField(aClass);
|
||||||
getSelectColum().add(new SelectFunc(cacheMap.get(LambdaUtils.getName(column)), getIndex(), alias, funcEnum));
|
getSelectColum().add(new SelectFunc(cacheMap.get(LambdaUtils.getName(column)), getIndex(), alias, funcEnum, isHasAlias(), getAlias()));
|
||||||
return getChildren();
|
return getChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,12 +191,14 @@ public interface Query<Children> extends Serializable {
|
|||||||
|
|
||||||
|
|
||||||
default <X> Children selectFunc(String sql, Function<SelectFunc.Func, SFunction<?, ?>[]> column, String alias) {
|
default <X> Children selectFunc(String sql, Function<SelectFunc.Func, SFunction<?, ?>[]> column, String alias) {
|
||||||
getSelectColum().add(new SelectFunc(alias, getIndex(), () -> sql, column.apply(new SelectFunc.Func())));
|
getSelectColum().add(new SelectFunc(alias, getIndex(), () -> sql, column.apply(new SelectFunc.Func()),
|
||||||
|
isHasAlias(), getAlias()));
|
||||||
return getChildren();
|
return getChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
default <X, S> Children selectFunc(String sql, Function<SelectFunc.Func, SFunction<?, ?>[]> column, SFunction<S, ?> alias) {
|
default <X, S> Children selectFunc(String sql, Function<SelectFunc.Func, SFunction<?, ?>[]> column, SFunction<S, ?> alias) {
|
||||||
getSelectColum().add(new SelectFunc(LambdaUtils.getName(alias), getIndex(), () -> sql, column.apply(new SelectFunc.Func())));
|
getSelectColum().add(new SelectFunc(LambdaUtils.getName(alias), getIndex(), () -> sql,
|
||||||
|
column.apply(new SelectFunc.Func()), isHasAlias(), getAlias()));
|
||||||
return getChildren();
|
return getChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
|||||||
* @param right 条件
|
* @param right 条件
|
||||||
*/
|
*/
|
||||||
default <T, X> Children leftJoin(Class<T> clazz, String alias, SFunction<T, ?> left, SFunction<X, ?> right) {
|
default <T, X> Children leftJoin(Class<T> clazz, String alias, SFunction<T, ?> left, SFunction<X, ?> right) {
|
||||||
return join(Constant.LEFT_JOIN, clazz,alias, left, right);
|
return join(Constant.LEFT_JOIN, clazz, alias, left, right);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -81,7 +81,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
|||||||
* @param function 条件
|
* @param function 条件
|
||||||
*/
|
*/
|
||||||
default <T> Children leftJoin(Class<T> clazz, String alias, WrapperFunction<MPJAbstractLambdaWrapper<Entity, ?>> function) {
|
default <T> Children leftJoin(Class<T> clazz, String alias, WrapperFunction<MPJAbstractLambdaWrapper<Entity, ?>> function) {
|
||||||
return join(Constant.LEFT_JOIN, clazz,alias, function);
|
return join(Constant.LEFT_JOIN, clazz, alias, function);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -92,7 +92,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
|||||||
* @param right 条件
|
* @param right 条件
|
||||||
*/
|
*/
|
||||||
default <T, X> Children leftJoin(Class<T> clazz, String alias, SFunction<T, ?> left, SFunction<X, ?> right, WrapperFunction<MPJLambdaWrapper<Entity>> ext) {
|
default <T, X> Children leftJoin(Class<T> clazz, String alias, SFunction<T, ?> left, SFunction<X, ?> right, WrapperFunction<MPJLambdaWrapper<Entity>> ext) {
|
||||||
return join(Constant.LEFT_JOIN, clazz,alias, left, right, ext);
|
return join(Constant.LEFT_JOIN, clazz, alias, left, right, ext);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -104,7 +104,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
|||||||
* @param consumer 条件
|
* @param consumer 条件
|
||||||
*/
|
*/
|
||||||
default <T> Children leftJoin(Class<T> clazz, String alias, BiConsumer<MPJAbstractLambdaWrapper<Entity, ?>, MPJLambdaWrapper<Entity>> consumer) {
|
default <T> Children leftJoin(Class<T> clazz, String alias, BiConsumer<MPJAbstractLambdaWrapper<Entity, ?>, MPJLambdaWrapper<Entity>> consumer) {
|
||||||
return join(Constant.LEFT_JOIN, clazz,alias, consumer);
|
return join(Constant.LEFT_JOIN, clazz, alias, consumer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -139,28 +139,28 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
|||||||
* ignore 参考 left join
|
* ignore 参考 left join
|
||||||
*/
|
*/
|
||||||
default <T, X> Children rightJoin(Class<T> clazz, String alias, SFunction<T, ?> left, SFunction<X, ?> right) {
|
default <T, X> Children rightJoin(Class<T> clazz, String alias, SFunction<T, ?> left, SFunction<X, ?> right) {
|
||||||
return join(Constant.RIGHT_JOIN, clazz,alias, left, right);
|
return join(Constant.RIGHT_JOIN, clazz, alias, left, right);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ignore 参考 left join
|
* ignore 参考 left join
|
||||||
*/
|
*/
|
||||||
default <T> Children rightJoin(Class<T> clazz, String alias, WrapperFunction<MPJAbstractLambdaWrapper<Entity, ?>> function) {
|
default <T> Children rightJoin(Class<T> clazz, String alias, WrapperFunction<MPJAbstractLambdaWrapper<Entity, ?>> function) {
|
||||||
return join(Constant.RIGHT_JOIN, clazz,alias, function);
|
return join(Constant.RIGHT_JOIN, clazz, alias, function);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ignore 参考 left join
|
* ignore 参考 left join
|
||||||
*/
|
*/
|
||||||
default <T, X> Children rightJoin(Class<T> clazz, String alias, SFunction<T, ?> left, SFunction<X, ?> right, WrapperFunction<MPJLambdaWrapper<Entity>> ext) {
|
default <T, X> Children rightJoin(Class<T> clazz, String alias, SFunction<T, ?> left, SFunction<X, ?> right, WrapperFunction<MPJLambdaWrapper<Entity>> ext) {
|
||||||
return join(Constant.RIGHT_JOIN, clazz,alias, left, right, ext);
|
return join(Constant.RIGHT_JOIN, clazz, alias, left, right, ext);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ignore 参考 left join
|
* ignore 参考 left join
|
||||||
*/
|
*/
|
||||||
default <T, X> Children rightJoin(Class<T> clazz, String alias, BiConsumer<MPJAbstractLambdaWrapper<Entity, ?>, MPJLambdaWrapper<Entity>> consumer) {
|
default <T, X> Children rightJoin(Class<T> clazz, String alias, BiConsumer<MPJAbstractLambdaWrapper<Entity, ?>, MPJLambdaWrapper<Entity>> consumer) {
|
||||||
return join(Constant.RIGHT_JOIN, clazz,alias, consumer);
|
return join(Constant.RIGHT_JOIN, clazz, alias, consumer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -197,28 +197,28 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
|||||||
* ignore 参考 left join
|
* ignore 参考 left join
|
||||||
*/
|
*/
|
||||||
default <T, X> Children innerJoin(Class<T> clazz, String alias, SFunction<T, ?> left, SFunction<X, ?> right) {
|
default <T, X> Children innerJoin(Class<T> clazz, String alias, SFunction<T, ?> left, SFunction<X, ?> right) {
|
||||||
return join(Constant.INNER_JOIN, clazz,alias, on -> on.eq(left, right));
|
return join(Constant.INNER_JOIN, clazz, alias, on -> on.eq(left, right));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ignore 参考 left join
|
* ignore 参考 left join
|
||||||
*/
|
*/
|
||||||
default <T> Children innerJoin(Class<T> clazz, String alias, WrapperFunction<MPJAbstractLambdaWrapper<Entity, ?>> function) {
|
default <T> Children innerJoin(Class<T> clazz, String alias, WrapperFunction<MPJAbstractLambdaWrapper<Entity, ?>> function) {
|
||||||
return join(Constant.INNER_JOIN, clazz,alias, function);
|
return join(Constant.INNER_JOIN, clazz, alias, function);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ignore 参考 left join
|
* ignore 参考 left join
|
||||||
*/
|
*/
|
||||||
default <T, X> Children innerJoin(Class<T> clazz, String alias, SFunction<T, ?> left, SFunction<X, ?> right, WrapperFunction<MPJLambdaWrapper<Entity>> ext) {
|
default <T, X> Children innerJoin(Class<T> clazz, String alias, SFunction<T, ?> left, SFunction<X, ?> right, WrapperFunction<MPJLambdaWrapper<Entity>> ext) {
|
||||||
return join(Constant.INNER_JOIN, clazz,alias, left, right, ext);
|
return join(Constant.INNER_JOIN, clazz, alias, left, right, ext);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ignore 参考 left join
|
* ignore 参考 left join
|
||||||
*/
|
*/
|
||||||
default <T> Children innerJoin(Class<T> clazz, String alias, BiConsumer<MPJAbstractLambdaWrapper<Entity, ?>, MPJLambdaWrapper<Entity>> consumer) {
|
default <T> Children innerJoin(Class<T> clazz, String alias, BiConsumer<MPJAbstractLambdaWrapper<Entity, ?>, MPJLambdaWrapper<Entity>> consumer) {
|
||||||
return join(Constant.INNER_JOIN, clazz,alias, consumer);
|
return join(Constant.INNER_JOIN, clazz, alias, consumer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -253,28 +253,28 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
|||||||
* ignore 参考 left join
|
* ignore 参考 left join
|
||||||
*/
|
*/
|
||||||
default <T, X> Children fullJoin(Class<T> clazz, String alias, SFunction<T, ?> left, SFunction<X, ?> right) {
|
default <T, X> Children fullJoin(Class<T> clazz, String alias, SFunction<T, ?> left, SFunction<X, ?> right) {
|
||||||
return join(Constant.FULL_JOIN, clazz,alias, left, right);
|
return join(Constant.FULL_JOIN, clazz, alias, left, right);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ignore 参考 left join
|
* ignore 参考 left join
|
||||||
*/
|
*/
|
||||||
default <T> Children fullJoin(Class<T> clazz, String alias, WrapperFunction<MPJAbstractLambdaWrapper<Entity, ?>> function) {
|
default <T> Children fullJoin(Class<T> clazz, String alias, WrapperFunction<MPJAbstractLambdaWrapper<Entity, ?>> function) {
|
||||||
return join(Constant.FULL_JOIN, clazz,alias, function);
|
return join(Constant.FULL_JOIN, clazz, alias, function);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ignore 参考 left join
|
* ignore 参考 left join
|
||||||
*/
|
*/
|
||||||
default <T, X> Children fullJoin(Class<T> clazz, String alias, SFunction<T, ?> left, SFunction<X, ?> right, WrapperFunction<MPJLambdaWrapper<Entity>> ext) {
|
default <T, X> Children fullJoin(Class<T> clazz, String alias, SFunction<T, ?> left, SFunction<X, ?> right, WrapperFunction<MPJLambdaWrapper<Entity>> ext) {
|
||||||
return join(Constant.FULL_JOIN, clazz,alias, left, right, ext);
|
return join(Constant.FULL_JOIN, clazz, alias, left, right, ext);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ignore 参考 left join
|
* ignore 参考 left join
|
||||||
*/
|
*/
|
||||||
default <T> Children fullJoin(Class<T> clazz, String alias, BiConsumer<MPJAbstractLambdaWrapper<Entity, ?>, MPJLambdaWrapper<Entity>> consumer) {
|
default <T> Children fullJoin(Class<T> clazz, String alias, BiConsumer<MPJAbstractLambdaWrapper<Entity, ?>, MPJLambdaWrapper<Entity>> consumer) {
|
||||||
return join(Constant.FULL_JOIN, clazz,alias, consumer);
|
return join(Constant.FULL_JOIN, clazz, alias, consumer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -330,7 +330,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
|||||||
* @param right 扩展 用于关联表的 select 和 where
|
* @param right 扩展 用于关联表的 select 和 where
|
||||||
*/
|
*/
|
||||||
default <T, X> Children join(String keyWord, Class<T> clazz, String alias, SFunction<T, ?> left, SFunction<X, ?> right) {
|
default <T, X> Children join(String keyWord, Class<T> clazz, String alias, SFunction<T, ?> left, SFunction<X, ?> right) {
|
||||||
return join(keyWord, clazz,alias, on -> on.eq(left, right));
|
return join(keyWord, clazz, alias, on -> on.eq(left, right));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -342,7 +342,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
|||||||
* @param function 条件
|
* @param function 条件
|
||||||
*/
|
*/
|
||||||
default <T> Children join(String keyWord, Class<T> clazz, String alias, WrapperFunction<MPJAbstractLambdaWrapper<Entity, ?>> function) {
|
default <T> Children join(String keyWord, Class<T> clazz, String alias, WrapperFunction<MPJAbstractLambdaWrapper<Entity, ?>> function) {
|
||||||
return join(keyWord, clazz,alias, (on, e) -> function.apply(on));
|
return join(keyWord, clazz, alias, (on, e) -> function.apply(on));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -353,7 +353,7 @@ public interface QueryJoin<Children, Entity> extends MPJBaseJoin<Entity>, String
|
|||||||
* @param right 条件
|
* @param right 条件
|
||||||
*/
|
*/
|
||||||
default <T, X> Children join(String keyWord, Class<T> clazz, String alias, SFunction<T, ?> left, SFunction<X, ?> right, WrapperFunction<MPJLambdaWrapper<Entity>> ext) {
|
default <T, X> Children join(String keyWord, Class<T> clazz, String alias, SFunction<T, ?> left, SFunction<X, ?> right, WrapperFunction<MPJLambdaWrapper<Entity>> ext) {
|
||||||
return join(keyWord, clazz,alias, (on, e) -> {
|
return join(keyWord, clazz, alias, (on, e) -> {
|
||||||
on.eq(left, right);
|
on.eq(left, right);
|
||||||
ext.apply(e);
|
ext.apply(e);
|
||||||
});
|
});
|
||||||
|
@ -168,15 +168,14 @@ public class MybatisLabel<E, T> {
|
|||||||
/**
|
/**
|
||||||
* 嵌套
|
* 嵌套
|
||||||
*/
|
*/
|
||||||
public <A, B> Builder<E, T> association(Integer index, Class<A> child, SFunction<T, B> dtoField) {
|
public <A, B> Builder<E, T> association(String index, Class<A> child, SFunction<T, B> dtoField) {
|
||||||
Class<T> dtoClass = LambdaUtils.getEntityClass(dtoField);
|
Class<T> dtoClass = LambdaUtils.getEntityClass(dtoField);
|
||||||
Map<String, Field> fieldMap = MPJReflectionKit.getFieldMap(dtoClass);
|
Map<String, Field> fieldMap = MPJReflectionKit.getFieldMap(dtoClass);
|
||||||
String dtoFieldName = LambdaUtils.getName(dtoField);
|
String dtoFieldName = LambdaUtils.getName(dtoField);
|
||||||
Field field = fieldMap.get(dtoFieldName);
|
Field field = fieldMap.get(dtoFieldName);
|
||||||
Assert.isFalse(Collection.class.isAssignableFrom(field.getType()), "association 不支持集合类");
|
Assert.isFalse(Collection.class.isAssignableFrom(field.getType()), "association 不支持集合类");
|
||||||
MybatisLabel.Builder<A, B> builder;
|
MybatisLabel.Builder<A, B> builder;
|
||||||
builder = new MybatisLabel.Builder<>(Objects.isNull(index) ? null : index.toString(),
|
builder = new MybatisLabel.Builder<>(index, dtoFieldName, child, field.getType(), (Class<B>) field.getType(), true);
|
||||||
dtoFieldName, child, field.getType(), (Class<B>) field.getType(), true);
|
|
||||||
mybatisLabel.mybatisLabels.add(builder.build());
|
mybatisLabel.mybatisLabels.add(builder.build());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -189,14 +188,13 @@ public class MybatisLabel<E, T> {
|
|||||||
/**
|
/**
|
||||||
* 嵌套
|
* 嵌套
|
||||||
*/
|
*/
|
||||||
public <A, B> Builder<E, T> association(Integer index, Class<A> child, SFunction<T, B> dtoField,
|
public <A, B> Builder<E, T> association(String index, Class<A> child, SFunction<T, B> dtoField,
|
||||||
MFunc<MybatisLabel.Builder<A, B>> collection) {
|
MFunc<MybatisLabel.Builder<A, B>> collection) {
|
||||||
String dtoFieldName = LambdaUtils.getName(dtoField);
|
String dtoFieldName = LambdaUtils.getName(dtoField);
|
||||||
Class<T> dtoClass = LambdaUtils.getEntityClass(dtoField);
|
Class<T> dtoClass = LambdaUtils.getEntityClass(dtoField);
|
||||||
Field field = MPJReflectionKit.getFieldMap(dtoClass).get(dtoFieldName);
|
Field field = MPJReflectionKit.getFieldMap(dtoClass).get(dtoFieldName);
|
||||||
Assert.isFalse(Collection.class.isAssignableFrom(field.getType()), "association 不支持集合类");
|
Assert.isFalse(Collection.class.isAssignableFrom(field.getType()), "association 不支持集合类");
|
||||||
MybatisLabel.Builder<A, B> builder = new MybatisLabel.Builder<>(Objects.isNull(index) ? null : index.toString(),
|
MybatisLabel.Builder<A, B> builder = new MybatisLabel.Builder<>(index, dtoFieldName, child, field.getType(), (Class<B>) field.getType(), false);
|
||||||
dtoFieldName, child, field.getType(), (Class<B>) field.getType(), false);
|
|
||||||
mybatisLabel.mybatisLabels.add(collection.apply(builder).build());
|
mybatisLabel.mybatisLabels.add(collection.apply(builder).build());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,11 @@ public interface Select {
|
|||||||
|
|
||||||
Class<?> getClazz();
|
Class<?> getClazz();
|
||||||
|
|
||||||
String getIndex();
|
Integer getIndex();
|
||||||
|
|
||||||
|
boolean isHasTableAlias();
|
||||||
|
|
||||||
|
String getTableAlias();
|
||||||
|
|
||||||
boolean isPk();
|
boolean isPk();
|
||||||
|
|
||||||
@ -39,7 +43,7 @@ public interface Select {
|
|||||||
|
|
||||||
boolean isFunc();
|
boolean isFunc();
|
||||||
|
|
||||||
SFunction<?,?>[] getArgs();
|
SFunction<?, ?>[] getArgs();
|
||||||
|
|
||||||
BaseFuncEnum getFunc();
|
BaseFuncEnum getFunc();
|
||||||
|
|
||||||
|
@ -18,17 +18,23 @@ public class SelectAlias implements Select {
|
|||||||
|
|
||||||
private final SelectCache cache;
|
private final SelectCache cache;
|
||||||
|
|
||||||
private final String index;
|
private final Integer index;
|
||||||
|
|
||||||
private final boolean hasAlias;
|
private final boolean hasAlias;
|
||||||
|
|
||||||
private final String alias;
|
private final String alias;
|
||||||
|
|
||||||
public SelectAlias(SelectCache cache, String index, String alias) {
|
private final boolean hasTableAlias;
|
||||||
|
|
||||||
|
private final String tableAlias;
|
||||||
|
|
||||||
|
public SelectAlias(SelectCache cache, Integer index, String alias, boolean hasTableAlias, String tableAlias) {
|
||||||
this.cache = cache;
|
this.cache = cache;
|
||||||
this.index = index;
|
this.index = index;
|
||||||
this.hasAlias = true;
|
this.hasAlias = true;
|
||||||
this.alias = alias;
|
this.alias = alias;
|
||||||
|
this.hasTableAlias = hasTableAlias;
|
||||||
|
this.tableAlias = tableAlias;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ import java.util.Objects;
|
|||||||
@Getter
|
@Getter
|
||||||
public class SelectFunc implements Select {
|
public class SelectFunc implements Select {
|
||||||
|
|
||||||
private final String index;
|
private final Integer index;
|
||||||
|
|
||||||
private final SelectCache cache;
|
private final SelectCache cache;
|
||||||
|
|
||||||
@ -34,8 +34,12 @@ public class SelectFunc implements Select {
|
|||||||
|
|
||||||
private final BaseFuncEnum func;
|
private final BaseFuncEnum func;
|
||||||
|
|
||||||
|
private final boolean hasTableAlias;
|
||||||
|
|
||||||
public SelectFunc(SelectCache cache, String index, String alias, BaseFuncEnum func) {
|
private final String tableAlias;
|
||||||
|
|
||||||
|
|
||||||
|
public SelectFunc(SelectCache cache, Integer index, String alias, BaseFuncEnum func, boolean hasTableAlias, String tableAlias) {
|
||||||
this.index = index;
|
this.index = index;
|
||||||
this.cache = cache;
|
this.cache = cache;
|
||||||
this.column = cache.getColumn();
|
this.column = cache.getColumn();
|
||||||
@ -44,9 +48,11 @@ public class SelectFunc implements Select {
|
|||||||
this.alias = alias;
|
this.alias = alias;
|
||||||
this.isFunc = true;
|
this.isFunc = true;
|
||||||
this.func = func;
|
this.func = func;
|
||||||
|
this.hasTableAlias = hasTableAlias;
|
||||||
|
this.tableAlias = tableAlias;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SelectFunc(String alias, String index, BaseFuncEnum func, String column) {
|
public SelectFunc(String alias, Integer index, BaseFuncEnum func, String column, boolean hasTableAlias, String tableAlias) {
|
||||||
this.index = index;
|
this.index = index;
|
||||||
this.column = column;
|
this.column = column;
|
||||||
this.args = null;
|
this.args = null;
|
||||||
@ -55,9 +61,11 @@ public class SelectFunc implements Select {
|
|||||||
this.alias = alias;
|
this.alias = alias;
|
||||||
this.isFunc = true;
|
this.isFunc = true;
|
||||||
this.func = func;
|
this.func = func;
|
||||||
|
this.hasTableAlias = hasTableAlias;
|
||||||
|
this.tableAlias = tableAlias;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SelectFunc(String alias, String index, BaseFuncEnum func, SFunction<?, ?>[] args) {
|
public SelectFunc(String alias, Integer index, BaseFuncEnum func, SFunction<?, ?>[] args, boolean hasTableAlias, String tableAlias) {
|
||||||
this.index = index;
|
this.index = index;
|
||||||
this.column = null;
|
this.column = null;
|
||||||
this.args = args;
|
this.args = args;
|
||||||
@ -66,6 +74,8 @@ public class SelectFunc implements Select {
|
|||||||
this.alias = alias;
|
this.alias = alias;
|
||||||
this.isFunc = true;
|
this.isFunc = true;
|
||||||
this.func = func;
|
this.func = func;
|
||||||
|
this.hasTableAlias = hasTableAlias;
|
||||||
|
this.tableAlias = tableAlias;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -18,7 +18,7 @@ import java.lang.reflect.Field;
|
|||||||
@Getter
|
@Getter
|
||||||
public class SelectLabel implements Select {
|
public class SelectLabel implements Select {
|
||||||
|
|
||||||
private final String index;
|
private final Integer index;
|
||||||
|
|
||||||
private final SelectCache cache;
|
private final SelectCache cache;
|
||||||
|
|
||||||
@ -30,22 +30,30 @@ public class SelectLabel implements Select {
|
|||||||
|
|
||||||
private final String alias;
|
private final String alias;
|
||||||
|
|
||||||
public SelectLabel(SelectCache cache, String index, Class<?> tagClass, Field tagField) {
|
private final boolean hasTableAlias;
|
||||||
|
|
||||||
|
private final String tableAlias;
|
||||||
|
|
||||||
|
public SelectLabel(SelectCache cache, Integer index, Class<?> tagClass, Field tagField, boolean hasTableAlias, String tableAlias) {
|
||||||
this.cache = cache;
|
this.cache = cache;
|
||||||
this.index = index;
|
this.index = index;
|
||||||
this.tagClass = tagClass;
|
this.tagClass = tagClass;
|
||||||
this.tagField = tagField;
|
this.tagField = tagField;
|
||||||
this.hasAlias = false;
|
this.hasAlias = false;
|
||||||
this.alias = null;
|
this.alias = null;
|
||||||
|
this.hasTableAlias = hasTableAlias;
|
||||||
|
this.tableAlias = tableAlias;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SelectLabel(SelectCache cache, String index, Class<?> tagClass, Field tagField, String column) {
|
public SelectLabel(SelectCache cache, Integer index, Class<?> tagClass, Field tagField, String column, boolean hasTableAlias, String tableAlias) {
|
||||||
this.cache = cache;
|
this.cache = cache;
|
||||||
this.index = index;
|
this.index = index;
|
||||||
this.tagClass = tagClass;
|
this.tagClass = tagClass;
|
||||||
this.tagField = tagField;
|
this.tagField = tagField;
|
||||||
this.hasAlias = true;
|
this.hasAlias = true;
|
||||||
this.alias = column;
|
this.alias = column;
|
||||||
|
this.hasTableAlias = hasTableAlias;
|
||||||
|
this.tableAlias = tableAlias;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -15,13 +15,19 @@ import org.apache.ibatis.type.TypeHandler;
|
|||||||
@Getter
|
@Getter
|
||||||
public class SelectNormal implements Select {
|
public class SelectNormal implements Select {
|
||||||
|
|
||||||
private final String index;
|
private final Integer index;
|
||||||
|
|
||||||
private final SelectCache cache;
|
private final SelectCache cache;
|
||||||
|
|
||||||
public SelectNormal(SelectCache cache, String index) {
|
private final boolean hasTableAlias;
|
||||||
|
|
||||||
|
private final String tableAlias;
|
||||||
|
|
||||||
|
public SelectNormal(SelectCache cache, Integer index, boolean hasTableAlias, String tableAlias) {
|
||||||
this.cache = cache;
|
this.cache = cache;
|
||||||
this.index = index;
|
this.index = index;
|
||||||
|
this.hasTableAlias = hasTableAlias;
|
||||||
|
this.tableAlias = tableAlias;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,8 +14,14 @@ import org.apache.ibatis.type.TypeHandler;
|
|||||||
public class SelectString implements Select {
|
public class SelectString implements Select {
|
||||||
private final String column;
|
private final String column;
|
||||||
|
|
||||||
public SelectString(String column) {
|
private final boolean hasTableAlias;
|
||||||
|
|
||||||
|
private final String tableAlias;
|
||||||
|
|
||||||
|
public SelectString(String column, boolean hasTableAlias, String tableAlias) {
|
||||||
this.column = column;
|
this.column = column;
|
||||||
|
this.hasTableAlias = hasTableAlias;
|
||||||
|
this.tableAlias = tableAlias;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -24,10 +30,20 @@ public class SelectString implements Select {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getIndex() {
|
public Integer getIndex() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isHasTableAlias() {
|
||||||
|
return this.hasTableAlias;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTableAlias() {
|
||||||
|
return this.tableAlias;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPk() {
|
public boolean isPk() {
|
||||||
return false;
|
return false;
|
||||||
|
@ -7,11 +7,11 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.github.yulichang</groupId>
|
<groupId>com.github.yulichang</groupId>
|
||||||
<artifactId>mybatis-plus-join-root</artifactId>
|
<artifactId>mybatis-plus-join-root</artifactId>
|
||||||
<version>1.3.11</version>
|
<version>1.4.2.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>mybatis-plus-join-test</artifactId>
|
<artifactId>mybatis-plus-join-test</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>1.3.11</version>
|
<version>1.4.2.2</version>
|
||||||
|
|
||||||
<name>mybatis-plus-join-test</name>
|
<name>mybatis-plus-join-test</name>
|
||||||
|
|
||||||
@ -85,14 +85,14 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.yulichang</groupId>
|
<groupId>com.github.yulichang</groupId>
|
||||||
<artifactId>mybatis-plus-join-boot-starter</artifactId>
|
<artifactId>mybatis-plus-join-boot-starter</artifactId>
|
||||||
<version>1.3.11</version>
|
<version>1.4.2.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- PageHelper 兼容性测试 -->
|
<!-- PageHelper 兼容性测试 -->
|
||||||
<!-- <dependency>-->
|
<!-- <dependency>-->
|
||||||
<!-- <groupId>com.github.pagehelper</groupId>-->
|
<!-- <groupId>com.github.pagehelper</groupId>-->
|
||||||
<!-- <artifactId>pagehelper-spring-boot-starter</artifactId>-->
|
<!-- <artifactId>pagehelper-spring-boot-starter</artifactId>-->
|
||||||
<!-- <version>1.4.5</version>-->
|
<!-- <version>1.4.6</version>-->
|
||||||
<!-- </dependency>-->
|
<!-- </dependency>-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
@ -101,7 +101,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baomidou</groupId>
|
<groupId>com.baomidou</groupId>
|
||||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||||
<version>3.5.2</version>
|
<version>3.4.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.github.yulichang</groupId>
|
<groupId>com.github.yulichang</groupId>
|
||||||
<artifactId>mybatis-plus-join-test</artifactId>
|
<artifactId>mybatis-plus-join-test</artifactId>
|
||||||
<version>1.3.11</version>
|
<version>1.4.2.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.github.yulichang</groupId>
|
<groupId>com.github.yulichang</groupId>
|
||||||
<artifactId>mybatis-plus-join-test</artifactId>
|
<artifactId>mybatis-plus-join-test</artifactId>
|
||||||
<version>1.3.11</version>
|
<version>1.4.2.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
package com.github.yulichang.test.join.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName("user_dto")
|
||||||
|
public class UserDto {
|
||||||
|
|
||||||
|
@TableId
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
private Integer userId;
|
||||||
|
|
||||||
|
private Integer createBy;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String createName;
|
||||||
|
|
||||||
|
private Integer updateBy;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String updateName;
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.github.yulichang.test.join.mapper;
|
||||||
|
|
||||||
|
import com.github.yulichang.base.MPJBaseMapper;
|
||||||
|
import com.github.yulichang.test.join.entity.UserDto;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface UserDTOMapper extends MPJBaseMapper<UserDto> {
|
||||||
|
}
|
@ -45,3 +45,14 @@ create table address
|
|||||||
address varchar(255) null,
|
address varchar(255) null,
|
||||||
del bit
|
del bit
|
||||||
);
|
);
|
||||||
|
|
||||||
|
create table user_dto
|
||||||
|
(
|
||||||
|
id int auto_increment
|
||||||
|
primary key,
|
||||||
|
user_id int not null,
|
||||||
|
create_by int not null,
|
||||||
|
update_by int not null,
|
||||||
|
version int not null,
|
||||||
|
del bit null
|
||||||
|
);
|
@ -8,13 +8,15 @@ import com.github.yulichang.test.join.dto.UserDTO;
|
|||||||
import com.github.yulichang.test.join.entity.AddressDO;
|
import com.github.yulichang.test.join.entity.AddressDO;
|
||||||
import com.github.yulichang.test.join.entity.AreaDO;
|
import com.github.yulichang.test.join.entity.AreaDO;
|
||||||
import com.github.yulichang.test.join.entity.UserDO;
|
import com.github.yulichang.test.join.entity.UserDO;
|
||||||
|
import com.github.yulichang.test.join.entity.UserDto;
|
||||||
|
import com.github.yulichang.test.join.mapper.UserDTOMapper;
|
||||||
import com.github.yulichang.test.join.mapper.UserMapper;
|
import com.github.yulichang.test.join.mapper.UserMapper;
|
||||||
import com.github.yulichang.toolkit.MPJWrappers;
|
import com.github.yulichang.toolkit.MPJWrappers;
|
||||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -30,9 +32,12 @@ import java.util.Map;
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
class LambdaWrapperTest {
|
class LambdaWrapperTest {
|
||||||
@Resource
|
@Autowired
|
||||||
private UserMapper userMapper;
|
private UserMapper userMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserDTOMapper userDTOMapper;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testJoin() {
|
void testJoin() {
|
||||||
MPJLambdaWrapper<UserDO> wrapper = new MPJLambdaWrapper<UserDO>()
|
MPJLambdaWrapper<UserDO> wrapper = new MPJLambdaWrapper<UserDO>()
|
||||||
@ -54,8 +59,8 @@ class LambdaWrapperTest {
|
|||||||
.selectAll(UserDO.class)
|
.selectAll(UserDO.class)
|
||||||
.selectCollection(AddressDO.class, UserDTO::getAddressList, addr -> addr
|
.selectCollection(AddressDO.class, UserDTO::getAddressList, addr -> addr
|
||||||
.association(AreaDO.class, AddressDTO::getArea))
|
.association(AreaDO.class, AddressDTO::getArea))
|
||||||
.leftJoin(AddressDO::getUserId, UserDO::getId)
|
.leftJoin(AddressDO.class, AddressDO::getUserId, UserDO::getId)
|
||||||
.leftJoin(AreaDO::getId, AddressDO::getAreaId)
|
.leftJoin(AreaDO.class, AreaDO::getId, AddressDO::getAreaId)
|
||||||
.orderByDesc(UserDO::getId);
|
.orderByDesc(UserDO::getId);
|
||||||
List<UserDTO> list = userMapper.selectJoinList(UserDTO.class, wrapper);
|
List<UserDTO> list = userMapper.selectJoinList(UserDTO.class, wrapper);
|
||||||
|
|
||||||
@ -92,20 +97,49 @@ class LambdaWrapperTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testMSCache() {
|
void testMSCache() {
|
||||||
// MPJLambdaWrapper<UserDO> wrapper = new MPJLambdaWrapper<UserDO>()
|
// PageHelper.startPage(1, 10);
|
||||||
// .selectAll(UserDO.class)
|
MPJLambdaWrapper<UserDO> wrapper = new MPJLambdaWrapper<UserDO>()
|
||||||
// .leftJoin(AddressDO.class, AddressDO::getUserId, UserDO::getId)
|
.selectAll(UserDO.class)
|
||||||
// .leftJoin(AreaDO.class, AreaDO::getId, AddressDO::getAreaId);
|
.setEntity(new UserDO() {{
|
||||||
// List<UserDTO> list = userMapper.selectJoinList(UserDTO.class, wrapper);
|
setId(1);
|
||||||
|
}})
|
||||||
|
// .eq(UserDO::getId,1)
|
||||||
|
.orderByAsc(UserDO::getId, UserDO::getName);
|
||||||
|
|
||||||
MPJLambdaWrapper<UserDO> wrapper1 = new MPJLambdaWrapper<UserDO>()
|
System.out.println(wrapper.getSqlSegment());
|
||||||
|
System.out.println(wrapper.nonEmptyOfNormal());
|
||||||
|
System.out.println(wrapper.isEmptyOfNormal());
|
||||||
|
System.out.println("-----------------");
|
||||||
|
System.out.println(wrapper.nonEmptyOfWhere());
|
||||||
|
System.out.println(wrapper.isEmptyOfWhere());
|
||||||
|
|
||||||
|
List<UserDO> list = userMapper.selectList(wrapper);
|
||||||
|
// list.forEach(System.out::println);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testMSCachee() {
|
||||||
|
MPJLambdaWrapper<UserDto> wrapper = new MPJLambdaWrapper<UserDto>("tt")
|
||||||
|
.selectAll(UserDto.class)
|
||||||
|
.leftJoin(UserDO.class, "ua", UserDO::getId, UserDto::getUserId, ext -> ext
|
||||||
|
.select(UserDO::getId))
|
||||||
|
.leftJoin(UserDO.class, "ub", UserDO::getId, UserDto::getCreateBy, ext -> ext
|
||||||
|
.select(UserDO::getImg))
|
||||||
|
.leftJoin(UserDO.class, "uc", UserDO::getId, UserDto::getUpdateBy);
|
||||||
|
userDTOMapper.selectJoinList(UserDto.class, wrapper);
|
||||||
|
System.out.println(1);
|
||||||
|
|
||||||
|
MPJLambdaWrapper<UserDO> w = new MPJLambdaWrapper<UserDO>("tt")
|
||||||
|
.selectAll(UserDO.class)
|
||||||
|
.leftJoin(UserDO.class, "ua", UserDO::getId, UserDO::getPid, ext -> ext
|
||||||
.select(UserDO::getId)
|
.select(UserDO::getId)
|
||||||
.selectAs(UserDO::getJson, UserDTO::getArea)
|
.eq(UserDO::getImg, UserDO::getName))
|
||||||
.leftJoin(AddressDO.class, AddressDO::getUserId, UserDO::getId)
|
.leftJoin(UserDO.class, "ub", UserDO::getId, UserDO::getCreateBy, ext -> ext
|
||||||
.leftJoin(AreaDO.class, AreaDO::getId, AddressDO::getAreaId);
|
.select(UserDO::getImg))
|
||||||
List<UserDTO> list1 = userMapper.selectJoinList(UserDTO.class, wrapper1);
|
.leftJoin(UserDO.class, "uc", UserDO::getId, UserDO::getUpdateBy)
|
||||||
|
.eq(UserDO::getId, UserDO::getId);
|
||||||
assert list1.get(0).getArea() != null;
|
userMapper.selectJoinList(UserDO.class, w);
|
||||||
|
System.out.println(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -113,26 +147,28 @@ class LambdaWrapperTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
void testInner() {
|
void testInner() {
|
||||||
// //自连接
|
//自连接
|
||||||
// MPJLambdaWrapper<UserDO> wrapper = new MPJLambdaWrapper<UserDO>()
|
MPJLambdaWrapper<UserDO> wrapper = new MPJLambdaWrapper<UserDO>()
|
||||||
// .disableSubLogicDel()//关闭副表逻辑删除
|
.disableSubLogicDel()//关闭副表逻辑删除
|
||||||
//// .disableLogicDel()//关闭主表逻辑删除
|
// .disableLogicDel()//关闭主表逻辑删除
|
||||||
// .selectAll(UserDO.class)
|
.selectAll(UserDO.class)
|
||||||
// .selectCollection(UserDO.class, UserDO::getChildren)
|
.selectCollection(UserDO.class, UserDO::getChildren)
|
||||||
// .leftJoin(UserDO.class, UserDO::getPid, UserDO::getId);
|
.leftJoin(UserDO.class, UserDO::getPid, UserDO::getId);
|
||||||
// List<UserDO> list = userMapper.selectJoinList(UserDO.class, wrapper);
|
List<UserDO> list = userMapper.selectJoinList(UserDO.class, wrapper);
|
||||||
//// assert list.size() == 2 && list.get(0).getChildren().size() == 9;
|
// assert list.size() == 2 && list.get(0).getChildren().size() == 9;
|
||||||
// System.out.println(list);
|
System.out.println(list);
|
||||||
|
|
||||||
//关联一张表多次
|
//关联一张表多次
|
||||||
MPJLambdaWrapper<UserDO> w = new MPJLambdaWrapper<UserDO>()
|
MPJLambdaWrapper<UserDO> w = new MPJLambdaWrapper<UserDO>()
|
||||||
.disableLogicDel()
|
.disableLogicDel()
|
||||||
.disableSubLogicDel()
|
.disableSubLogicDel()
|
||||||
.selectAll(UserDO.class)
|
.selectAll(UserDO.class)
|
||||||
.leftJoin(UserDO.class, UserDO::getId, UserDO::getCreateBy, ext -> ext.selectAs(UserDO::getName, UserDO::getCreateName))
|
.leftJoin(UserDO.class, UserDO::getId, UserDO::getCreateBy, ext -> ext
|
||||||
|
.selectAs(UserDO::getName, UserDO::getCreateName))
|
||||||
.leftJoin(UserDO.class, (on, ext) -> {
|
.leftJoin(UserDO.class, (on, ext) -> {
|
||||||
on.eq(UserDO::getId, UserDO::getUpdateBy);
|
on.eq(UserDO::getId, UserDO::getUpdateBy);
|
||||||
ext.selectAs(UserDO::getName, UserDO::getUpdateName);
|
ext.selectAs(UserDO::getName, UserDO::getUpdateName)
|
||||||
|
.eq(UserDO::getId, UserDO::getUpdateBy);
|
||||||
})
|
})
|
||||||
.eq(UserDO::getId, UserDO::getId);
|
.eq(UserDO::getId, UserDO::getId);
|
||||||
List<UserDO> dos = userMapper.selectJoinList(UserDO.class, w);
|
List<UserDO> dos = userMapper.selectJoinList(UserDO.class, w);
|
||||||
@ -141,8 +177,8 @@ class LambdaWrapperTest {
|
|||||||
MPJLambdaWrapper<UserDO> wrapper1 = new MPJLambdaWrapper<UserDO>()
|
MPJLambdaWrapper<UserDO> wrapper1 = new MPJLambdaWrapper<UserDO>()
|
||||||
.disableSubLogicDel()
|
.disableSubLogicDel()
|
||||||
.selectAll(UserDO.class)
|
.selectAll(UserDO.class)
|
||||||
.selectCollection(1, UserDO.class, UserDO::getChildren, c -> c
|
.selectCollection("t1", UserDO.class, UserDO::getChildren, c -> c
|
||||||
.collection(2, UserDO.class, UserDO::getChildren))
|
.collection("t2", UserDO.class, UserDO::getChildren))
|
||||||
.leftJoin(UserDO.class, UserDO::getPid, UserDO::getId, ext -> ext
|
.leftJoin(UserDO.class, UserDO::getPid, UserDO::getId, ext -> ext
|
||||||
.selectAs(UserDO::getName, UserDO::getAlias)
|
.selectAs(UserDO::getName, UserDO::getAlias)
|
||||||
.leftJoin(UserDO.class, UserDO::getPid, UserDO::getId)
|
.leftJoin(UserDO.class, UserDO::getPid, UserDO::getId)
|
||||||
@ -210,7 +246,9 @@ class LambdaWrapperTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
void test1() {
|
void test1() {
|
||||||
IPage<UserDTO> iPage = userMapper.selectJoinPage(new Page<>(1, 10), UserDTO.class,
|
Page<Object> page = new Page<>(1, 10);
|
||||||
|
page.setSearchCount(false);
|
||||||
|
IPage<UserDTO> iPage = userMapper.selectJoinPage(page, UserDTO.class,
|
||||||
MPJWrappers.<UserDO>lambdaJoin()
|
MPJWrappers.<UserDO>lambdaJoin()
|
||||||
.selectAll(UserDO.class)
|
.selectAll(UserDO.class)
|
||||||
.select(AddressDO::getAddress)
|
.select(AddressDO::getAddress)
|
||||||
@ -231,8 +269,8 @@ class LambdaWrapperTest {
|
|||||||
.selectAll(UserDO.class)
|
.selectAll(UserDO.class)
|
||||||
.select(AddressDO::getAddress)
|
.select(AddressDO::getAddress)
|
||||||
.leftJoin(AddressDO.class, on -> on
|
.leftJoin(AddressDO.class, on -> on
|
||||||
.eq(AddressDO::getUserId, UserDO::getId)
|
.eq(UserDO::getId, AddressDO::getUserId)
|
||||||
.eq(AddressDO::getUserId, UserDO::getId))
|
.eq(UserDO::getId, AddressDO::getUserId))
|
||||||
.eq(UserDO::getId, 1)
|
.eq(UserDO::getId, 1)
|
||||||
.and(i -> i.eq(UserDO::getImg, "er")
|
.and(i -> i.eq(UserDO::getImg, "er")
|
||||||
.or()
|
.or()
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>mybatis-plus-join-test</artifactId>
|
<artifactId>mybatis-plus-join-test</artifactId>
|
||||||
<groupId>com.github.yulichang</groupId>
|
<groupId>com.github.yulichang</groupId>
|
||||||
<version>1.3.11</version>
|
<version>1.4.2.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -10,13 +10,13 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.yulichang</groupId>
|
<groupId>com.github.yulichang</groupId>
|
||||||
<artifactId>mybatis-plus-join-boot-starter</artifactId>
|
<artifactId>mybatis-plus-join-boot-starter</artifactId>
|
||||||
<version>1.4.2</version>
|
<version>1.4.2.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
-->
|
-->
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.github.yulichang</groupId>
|
<groupId>com.github.yulichang</groupId>
|
||||||
<artifactId>mybatis-plus-join</artifactId>
|
<artifactId>mybatis-plus-join</artifactId>
|
||||||
<version>1.4.2</version>
|
<version>1.4.2.2</version>
|
||||||
<name>mybatis-plus-join</name>
|
<name>mybatis-plus-join</name>
|
||||||
|
|
||||||
<description>An enhanced toolkit of Mybatis-Plus to simplify development.</description>
|
<description>An enhanced toolkit of Mybatis-Plus to simplify development.</description>
|
||||||
@ -53,147 +53,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.yulichang</groupId>
|
<groupId>com.github.yulichang</groupId>
|
||||||
<artifactId>mybatis-plus-join-boot-starter</artifactId>
|
<artifactId>mybatis-plus-join-boot-starter</artifactId>
|
||||||
<version>1.4.2</version>
|
<version>1.4.2.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
|
||||||
<version>2.2.1</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>attach-sources</id>
|
|
||||||
<goals>
|
|
||||||
<goal>jar-no-fork</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
|
||||||
<version>2.9.1</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>attach-javadocs</id>
|
|
||||||
<goals>
|
|
||||||
<goal>jar</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-gpg-plugin</artifactId>
|
|
||||||
<version>1.5</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>sign-artifacts</id>
|
|
||||||
<phase>verify</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>sign</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.sonatype.plugins</groupId>
|
|
||||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
|
||||||
<version>1.6.8</version>
|
|
||||||
<extensions>true</extensions>
|
|
||||||
<configuration>
|
|
||||||
<serverId>ossrh</serverId>
|
|
||||||
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
|
|
||||||
<autoReleaseAfterClose>true</autoReleaseAfterClose>
|
|
||||||
<stagingProgressTimeoutMinutes>30</stagingProgressTimeoutMinutes>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
<profiles>
|
|
||||||
<profile>
|
|
||||||
<id>disable-javadoc-doclint</id>
|
|
||||||
<activation>
|
|
||||||
<jdk>[1.8,)</jdk>
|
|
||||||
</activation>
|
|
||||||
<properties>
|
|
||||||
<additionalparam>-Xdoclint:none</additionalparam>
|
|
||||||
</properties>
|
|
||||||
</profile>
|
|
||||||
<profile>
|
|
||||||
<id>release</id>
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
|
||||||
<version>2.2.1</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>attach-sources</id>
|
|
||||||
<goals>
|
|
||||||
<goal>jar-no-fork</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
|
||||||
<version>2.9.1</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>attach-javadocs</id>
|
|
||||||
<goals>
|
|
||||||
<goal>jar</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-gpg-plugin</artifactId>
|
|
||||||
<version>1.5</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>sign-artifacts</id>
|
|
||||||
<phase>verify</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>sign</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.sonatype.plugins</groupId>
|
|
||||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
|
||||||
<version>1.6.8</version>
|
|
||||||
<extensions>true</extensions>
|
|
||||||
<configuration>
|
|
||||||
<serverId>ossrh</serverId>
|
|
||||||
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
|
|
||||||
<autoReleaseAfterClose>true</autoReleaseAfterClose>
|
|
||||||
<stagingProgressTimeoutMinutes>30</stagingProgressTimeoutMinutes>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</profile>
|
|
||||||
</profiles>
|
|
||||||
<distributionManagement>
|
|
||||||
<snapshotRepository>
|
|
||||||
<id>ossrh</id>
|
|
||||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
|
||||||
</snapshotRepository>
|
|
||||||
<repository>
|
|
||||||
<id>ossrh</id>
|
|
||||||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
|
||||||
</repository>
|
|
||||||
</distributionManagement>
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
141
pom.xml
141
pom.xml
@ -5,7 +5,7 @@
|
|||||||
<groupId>com.github.yulichang</groupId>
|
<groupId>com.github.yulichang</groupId>
|
||||||
<artifactId>mybatis-plus-join-root</artifactId>
|
<artifactId>mybatis-plus-join-root</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>1.4.2</version>
|
<version>1.4.2.2</version>
|
||||||
<name>mybatis-plus-join-root</name>
|
<name>mybatis-plus-join-root</name>
|
||||||
|
|
||||||
<description>An enhanced toolkit of Mybatis-Plus to simplify development.</description>
|
<description>An enhanced toolkit of Mybatis-Plus to simplify development.</description>
|
||||||
@ -44,143 +44,4 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
|
||||||
<version>2.2.1</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>attach-sources</id>
|
|
||||||
<goals>
|
|
||||||
<goal>jar-no-fork</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
|
||||||
<version>2.9.1</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>attach-javadocs</id>
|
|
||||||
<goals>
|
|
||||||
<goal>jar</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-gpg-plugin</artifactId>
|
|
||||||
<version>1.5</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>sign-artifacts</id>
|
|
||||||
<phase>verify</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>sign</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.sonatype.plugins</groupId>
|
|
||||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
|
||||||
<version>1.6.8</version>
|
|
||||||
<extensions>true</extensions>
|
|
||||||
<configuration>
|
|
||||||
<serverId>ossrh</serverId>
|
|
||||||
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
|
|
||||||
<autoReleaseAfterClose>true</autoReleaseAfterClose>
|
|
||||||
<stagingProgressTimeoutMinutes>30</stagingProgressTimeoutMinutes>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
<profiles>
|
|
||||||
<profile>
|
|
||||||
<id>disable-javadoc-doclint</id>
|
|
||||||
<activation>
|
|
||||||
<jdk>[1.8,)</jdk>
|
|
||||||
</activation>
|
|
||||||
<properties>
|
|
||||||
<additionalparam>-Xdoclint:none</additionalparam>
|
|
||||||
</properties>
|
|
||||||
</profile>
|
|
||||||
<profile>
|
|
||||||
<id>release</id>
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
|
||||||
<version>2.2.1</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>attach-sources</id>
|
|
||||||
<goals>
|
|
||||||
<goal>jar-no-fork</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
|
||||||
<version>2.9.1</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>attach-javadocs</id>
|
|
||||||
<goals>
|
|
||||||
<goal>jar</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-gpg-plugin</artifactId>
|
|
||||||
<version>1.5</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>sign-artifacts</id>
|
|
||||||
<phase>verify</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>sign</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.sonatype.plugins</groupId>
|
|
||||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
|
||||||
<version>1.6.8</version>
|
|
||||||
<extensions>true</extensions>
|
|
||||||
<configuration>
|
|
||||||
<serverId>ossrh</serverId>
|
|
||||||
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
|
|
||||||
<autoReleaseAfterClose>true</autoReleaseAfterClose>
|
|
||||||
<stagingProgressTimeoutMinutes>30</stagingProgressTimeoutMinutes>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</profile>
|
|
||||||
</profiles>
|
|
||||||
<distributionManagement>
|
|
||||||
<snapshotRepository>
|
|
||||||
<id>ossrh</id>
|
|
||||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
|
||||||
</snapshotRepository>
|
|
||||||
<repository>
|
|
||||||
<id>ossrh</id>
|
|
||||||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
|
||||||
</repository>
|
|
||||||
</distributionManagement>
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user