|
@@ -2,11 +2,13 @@ package com.ruoyi.system.service.impl;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
import com.ruoyi.common.annotation.DataScope;
|
|
|
import com.ruoyi.common.constant.UserConstants;
|
|
|
import com.ruoyi.common.core.domain.entity.SysRole;
|
|
@@ -435,16 +437,11 @@ public class SysUserServiceImpl implements ISysUserService
|
|
|
public String selectUserRoleGroup(Long userId)
|
|
|
{
|
|
|
List<SysRole> list = roleMapper.selectRolesByUserId(userId);
|
|
|
- StringBuffer idsStr = new StringBuffer();
|
|
|
- for (SysRole role : list)
|
|
|
+ if (CollectionUtils.isEmpty(list))
|
|
|
{
|
|
|
- idsStr.append(role.getRoleName()).append(",");
|
|
|
+ return StringUtils.EMPTY;
|
|
|
}
|
|
|
- if (StringUtils.isNotEmpty(idsStr.toString()))
|
|
|
- {
|
|
|
- return idsStr.substring(0, idsStr.length() - 1);
|
|
|
- }
|
|
|
- return idsStr.toString();
|
|
|
+ return list.stream().map(SysRole::getRoleName).collect(Collectors.joining(","));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -457,16 +454,11 @@ public class SysUserServiceImpl implements ISysUserService
|
|
|
public String selectUserPostGroup(Long userId)
|
|
|
{
|
|
|
List<SysPost> list = postMapper.selectPostsByUserId(userId);
|
|
|
- StringBuffer idsStr = new StringBuffer();
|
|
|
- for (SysPost post : list)
|
|
|
- {
|
|
|
- idsStr.append(post.getPostName()).append(",");
|
|
|
- }
|
|
|
- if (StringUtils.isNotEmpty(idsStr.toString()))
|
|
|
+ if (CollectionUtils.isEmpty(list))
|
|
|
{
|
|
|
- return idsStr.substring(0, idsStr.length() - 1);
|
|
|
+ return StringUtils.EMPTY;
|
|
|
}
|
|
|
- return idsStr.toString();
|
|
|
+ return list.stream().map(SysPost::getPostName).collect(Collectors.joining(","));
|
|
|
}
|
|
|
|
|
|
/**
|