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
public Page<TUser> getList(Page<TUser> page, TUser user) {
List<TUser> list = tUserMapper.getList(page, user);
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());
userList = tUserMapper.getUserRole(collect);
}
......
......@@ -35,6 +35,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
/**
* <pre>
......@@ -169,10 +170,27 @@ public class TUserController extends BaseController {
try {
TUser tUser = userService.selectById(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.forEach(r -> list1.add(r.getId()));
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);
} 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