!561 使用封装好的StreamUtils工具类代替项目中的部分stream操作

* refactor : 使用封装好的StreamUtils工具类代替项目中的部分stream操作
This commit is contained in:
DoubleH
2024-07-06 05:58:26 +00:00
committed by 疯狂的狮子Li
parent 0cb3105cea
commit 6cc24dc763
8 changed files with 43 additions and 10 deletions

View File

@ -37,7 +37,6 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
/**
* 角色 业务层处理
@ -106,7 +105,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
List<SysRoleVo> userRoles = baseMapper.selectRolesByUserId(userId);
List<SysRoleVo> roles = selectRoleAll();
// 使用HashSet提高查找效率
Set<Long> userRoleIds = userRoles.stream().map(SysRoleVo::getRoleId).collect(Collectors.toSet());
Set<Long> userRoleIds = StreamUtils.toSet(userRoles, SysRoleVo::getRoleId);
for (SysRoleVo role : roles) {
if (userRoleIds.contains(role.getRoleId())) {
role.setFlag(true);