mirror of
https://gitee.com/best_handsome/mybatis-plus-join
synced 2025-07-11 00:02:22 +08:00
增加连表查询分组指定别名字段
This commit is contained in:
parent
bbb64c5144
commit
2674d6e7b9
2
pom.xml
2
pom.xml
@ -4,7 +4,7 @@
|
|||||||
<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.2.6</version>
|
<version>1.2.7</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>
|
||||||
<url>https://github.com/yulichang/mybatis-plus-join</url>
|
<url>https://github.com/yulichang/mybatis-plus-join</url>
|
||||||
|
@ -23,6 +23,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static com.baomidou.mybatisplus.core.enums.SqlKeyword.GROUP_BY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 参考 {@link com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper}
|
* 参考 {@link com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper}
|
||||||
* Lambda 语法使用 Wrapper
|
* Lambda 语法使用 Wrapper
|
||||||
@ -277,6 +279,15 @@ public class MPJLambdaWrapper<T> extends MPJAbstractLambdaWrapper<T, MPJLambdaWr
|
|||||||
return typedThis;
|
return typedThis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R> MPJLambdaWrapper<T> groupBy(String... columns) {
|
||||||
|
return maybeDo(true, () -> {
|
||||||
|
final String finalOne = String.join(StringPool.COMMA, columns);
|
||||||
|
;
|
||||||
|
appendSqlSegments(GROUP_BY, () -> finalOne);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* select字段
|
* select字段
|
||||||
*/
|
*/
|
||||||
|
@ -12,7 +12,8 @@ package com.github.yulichang.wrapper.enums;
|
|||||||
* @author yulichang
|
* @author yulichang
|
||||||
*/
|
*/
|
||||||
public enum DefaultFuncEnum implements BaseFuncEnum {
|
public enum DefaultFuncEnum implements BaseFuncEnum {
|
||||||
|
DATE_FORMAT_Y_M_D("DATE_FORMAT(%s,'%%Y-%%m-%%d')"),
|
||||||
|
DATE_FORMAT_Y_M("DATE_FORMAT(%s,'%%Y-%%m')"),
|
||||||
SUM("SUM(%s)"),
|
SUM("SUM(%s)"),
|
||||||
COUNT("COUNT(%s)"),
|
COUNT("COUNT(%s)"),
|
||||||
COUNT_DISTINCT("COUNT(DISTINCT %s)"),
|
COUNT_DISTINCT("COUNT(DISTINCT %s)"),
|
||||||
|
@ -187,6 +187,8 @@ public interface Func<Children> extends Serializable {
|
|||||||
*/
|
*/
|
||||||
<R> Children groupBy(boolean condition, List<SFunction<R, ?>> columns);
|
<R> Children groupBy(boolean condition, List<SFunction<R, ?>> columns);
|
||||||
|
|
||||||
|
<R> Children groupBy(String... columns);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ignore
|
* ignore
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user