mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-21 02:25:56 +08:00
fix 修复 in查询错误问题 应使用list
This commit is contained in:
parent
f3d1f12190
commit
ae796842ae
@ -7,10 +7,9 @@ import lombok.AccessLevel;
|
|||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.springframework.util.AntPathMatcher;
|
import org.springframework.util.AntPathMatcher;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashSet;
|
import java.util.function.Function;
|
||||||
import java.util.List;
|
import java.util.stream.Collectors;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字符串工具类
|
* 字符串工具类
|
||||||
@ -265,4 +264,26 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T> List<T> splitTo(String str, Function<? super Object, T> mapper) {
|
||||||
|
if (isBlank(str)) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
return StrUtil.split(str, ",")
|
||||||
|
.stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.map(mapper)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> List<T> splitTo(String str, String separator, Function<? super Object, T> mapper) {
|
||||||
|
if (isBlank(str)) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
return StrUtil.split(str, separator)
|
||||||
|
.stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.map(mapper)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.*;
|
import com.baomidou.mybatisplus.core.toolkit.ReflectionKit;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.toolkit.Db;
|
import com.baomidou.mybatisplus.extension.toolkit.Db;
|
||||||
import com.ruoyi.common.core.utils.BeanCopyUtils;
|
import com.ruoyi.common.core.utils.BeanCopyUtils;
|
||||||
@ -17,6 +17,9 @@ import java.io.Serializable;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义 Mapper 接口, 实现 自定义扩展
|
* 自定义 Mapper 接口, 实现 自定义扩展
|
||||||
@ -193,4 +196,8 @@ public interface BaseMapperPlus<M, T, V> extends BaseMapper<T> {
|
|||||||
return (P) voPage;
|
return (P) voPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default <C> List<C> selectObjs(Wrapper<T> wrapper, Function<? super Object, C> mapper) {
|
||||||
|
return this.selectObjs(wrapper).stream().filter(Objects::nonNull).map(mapper).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -162,21 +162,19 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
|||||||
@Override
|
@Override
|
||||||
public List<Long> selectMenuListByPackageId(Long packageId) {
|
public List<Long> selectMenuListByPackageId(Long packageId) {
|
||||||
SysTenantPackage tenantPackage = sysTenantPackageMapper.selectById(packageId);
|
SysTenantPackage tenantPackage = sysTenantPackageMapper.selectById(packageId);
|
||||||
String menuIds = tenantPackage.getMenuIds();
|
List<Long> menuIds = StringUtils.splitTo(tenantPackage.getMenuIds(), Convert::toLong);
|
||||||
if (StringUtils.isBlank(menuIds)) {
|
if (CollUtil.isEmpty(menuIds)) {
|
||||||
return List.of();
|
return List.of();
|
||||||
}
|
}
|
||||||
List<Long> parentIds = null;
|
List<Long> parentIds = null;
|
||||||
if (tenantPackage.getMenuCheckStrictly()) {
|
if (tenantPackage.getMenuCheckStrictly()) {
|
||||||
parentIds = baseMapper.selectObjs(new LambdaQueryWrapper<SysMenu>()
|
parentIds = baseMapper.selectObjs(new LambdaQueryWrapper<SysMenu>()
|
||||||
.select(SysMenu::getParentId)
|
.select(SysMenu::getParentId)
|
||||||
.in(SysMenu::getMenuId, menuIds))
|
.in(SysMenu::getMenuId, menuIds), Convert::toLong);
|
||||||
.stream().distinct().map(Convert::toLong).toList();
|
|
||||||
}
|
}
|
||||||
return baseMapper.selectObjs(new LambdaQueryWrapper<SysMenu>()
|
return baseMapper.selectObjs(new LambdaQueryWrapper<SysMenu>()
|
||||||
.in(SysMenu::getMenuId, menuIds)
|
.in(SysMenu::getMenuId, menuIds)
|
||||||
.notIn(CollUtil.isNotEmpty(parentIds), SysMenu::getMenuId, parentIds))
|
.notIn(CollUtil.isNotEmpty(parentIds), SysMenu::getMenuId, parentIds), Convert::toLong);
|
||||||
.stream().map(Convert::toLong).toList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user