Commit f5c95683 authored by nie'hong's avatar nie'hong

获取用户信息时携带roleName

parent e44ffc0a
...@@ -60,7 +60,7 @@ public class TUserServiceImpl extends ServiceImpl<TUserMapper, TUser> implements ...@@ -60,7 +60,7 @@ public class TUserServiceImpl extends ServiceImpl<TUserMapper, TUser> implements
public Page<TUser> getList(Page<TUser> page, TUser user) { public Page<TUser> getList(Page<TUser> page, TUser user) {
List<TUser> list = tUserMapper.getList(page, user); List<TUser> list = tUserMapper.getList(page, user);
List<TUser> userList = new ArrayList<>(); List<TUser> userList = new ArrayList<>();
if (!CollectionUtils.isEmpty(list)) { if (!CollectionUtils.isEmpty(list) && "2".equals(user.getType())) {
List<String> collect = list.stream().map(TUser::getId).collect(Collectors.toList()); List<String> collect = list.stream().map(TUser::getId).collect(Collectors.toList());
userList = tUserMapper.getUserRole(collect); userList = tUserMapper.getUserRole(collect);
} }
......
...@@ -35,6 +35,7 @@ import org.springframework.web.bind.annotation.*; ...@@ -35,6 +35,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* <pre> * <pre>
...@@ -169,10 +170,27 @@ public class TUserController extends BaseController { ...@@ -169,10 +170,27 @@ public class TUserController extends BaseController {
try { try {
TUser tUser = userService.selectById(id); TUser tUser = userService.selectById(id);
List<Role> list = roleService.selectRoleByUserId(id); List<Role> list = roleService.selectRoleByUserId(id);
if (list != null && list.size() > 0 && list.get(0) != null) { /** 修改
* if (list != null && list.size() > 0 && list.get(0) != null) {
List<String> list1 = new ArrayList<>(); List<String> list1 = new ArrayList<>();
list.forEach(r -> list1.add(r.getId())); list.forEach(r -> list1.add(r.getId()));
tUser.setRoleList(list1); tUser.setRoleList(list1);
}
**/
List<String> collect = list.stream().map(Role::getId).collect(Collectors.toList());
tUser.setRoleList(collect);
// 管理员的类型
if (collect.contains("2") || collect.contains("17")) {
for (Role role : list) {
if ("2".equals(role.getId())) {
tUser.setRoleName(role.getName());
break;
}
if ("17".equals(role.getId())) {
tUser.setRoleName(role.getName());
break;
}
}
} }
return getResult(tUser); return getResult(tUser);
} catch (Exception e) { } catch (Exception e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment