mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-13 07:33:42 +08:00
更改目的 解决了什么问题(请提交到dev分支)
1.DictTypeTranslationImpl的修改为如果前方传入了非String字段,例如:我传入1.13的BigDecimal是无法和1.13的String匹配的,所以没转成功,
2.LambdaJoinQueryBuilder中加入两种groupBy方法,因为目前的join查询引用selectAs使用GROUP_CONCAT或者类似SQL语句需要groupBy,新增方法使用来引用
改动逻辑 这么写的思路(让作者更好的理解你的意图)
1.将传入字段转化为String进行对比
2.使用wrapper.groupBy,然后遍历字段进行groupBy
测试 都做了哪些测试(未经过测试不采纳)
1.已测试传入BigDecimal匹配成功
2.在多条sql语句测试过后均可以实现类似selectAs("GROUP_CONCAT(m_child.name SEPARATOR '、')", MaterialVo::getChildrenStatus)的功能
This commit is contained in:
parent
2933badb91
commit
4500a0b9b6
@ -25,6 +25,8 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||
|
||||
public static final String COLON = ":";
|
||||
|
||||
public static final String DOT = ".";
|
||||
|
||||
private static final AntPathMatcher ANT_PATH_MATCHER = new AntPathMatcher();
|
||||
|
||||
@Deprecated
|
||||
|
||||
@ -49,6 +49,39 @@ public final class LambdaJoinQueryBuilder<T> {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加分组查询。
|
||||
*
|
||||
* @param columns 分组字段
|
||||
* @return 当前联表查询构造辅助对象
|
||||
*/
|
||||
@SafeVarargs
|
||||
public final <E> LambdaJoinQueryBuilder<T> groupBy(SFunction<E, ?>... columns) {
|
||||
return groupBy(null, columns);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加分组查询。
|
||||
*
|
||||
* @param alias 表别名
|
||||
* @param columns 分组字段
|
||||
* @return 当前联表查询构造辅助对象
|
||||
*/
|
||||
@SafeVarargs
|
||||
public final <E> LambdaJoinQueryBuilder<T> groupBy(String alias, SFunction<E, ?>... columns) {
|
||||
if (columns == null) {
|
||||
return this;
|
||||
}
|
||||
for (SFunction<E, ?> column : columns) {
|
||||
String columnUnder = StringUtils.toUnderScoreCase(LambdaUtils.getName(column));
|
||||
if (StringUtils.isNotBlank(alias)) {
|
||||
columnUnder = alias + StringUtils.DOT + columnUnder;
|
||||
}
|
||||
wrapper.groupBy(columnUnder);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定主表查询字段。
|
||||
*
|
||||
|
||||
@ -33,7 +33,7 @@ public class DictTypeTranslationImpl implements TranslationInterface<String> {
|
||||
*/
|
||||
@Override
|
||||
public String translation(Object key, String other) {
|
||||
if (key instanceof String dictValue && StringUtils.isNotBlank(other)) {
|
||||
if (key.toString() instanceof String dictValue && StringUtils.isNotBlank(other)) {
|
||||
return dictService.getDictLabel(other, dictValue);
|
||||
}
|
||||
return null;
|
||||
@ -54,7 +54,7 @@ public class DictTypeTranslationImpl implements TranslationInterface<String> {
|
||||
Map<String, String> dictMap = dictService.getAllDictByDictType(other);
|
||||
Map<Object, String> result = new LinkedHashMap<>(keys.size());
|
||||
for (Object key : keys) {
|
||||
if (key instanceof String dictValue) {
|
||||
if (key.toString() instanceof String dictValue) {
|
||||
result.put(key, StreamUtils.join(
|
||||
StreamUtils.filter(Arrays.asList(dictValue.split(",")), StringUtils::isNotBlank),
|
||||
value -> dictMap.get(value.trim())
|
||||
|
||||
Loading…
Reference in New Issue
Block a user