|
@@ -2,6 +2,8 @@ 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;
|
|
@@ -25,6 +27,7 @@ import com.ruoyi.system.mapper.SysUserPostMapper;
|
|
|
import com.ruoyi.system.mapper.SysUserRoleMapper;
|
|
|
import com.ruoyi.system.service.ISysConfigService;
|
|
|
import com.ruoyi.system.service.ISysUserService;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
/**
|
|
|
* 用户 业务层处理
|
|
@@ -127,16 +130,11 @@ public class SysUserServiceImpl implements ISysUserService
|
|
|
public String selectUserRoleGroup(String userName)
|
|
|
{
|
|
|
List<SysRole> list = roleMapper.selectRolesByUserName(userName);
|
|
|
- StringBuffer idsStr = new StringBuffer();
|
|
|
- for (SysRole role : list)
|
|
|
- {
|
|
|
- idsStr.append(role.getRoleName()).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(SysRole::getRoleName).collect(Collectors.joining(","));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -149,16 +147,11 @@ public class SysUserServiceImpl implements ISysUserService
|
|
|
public String selectUserPostGroup(String userName)
|
|
|
{
|
|
|
List<SysPost> list = postMapper.selectPostsByUserName(userName);
|
|
|
- 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(","));
|
|
|
}
|
|
|
|
|
|
/**
|