use of cn.exrick.manager.dto.RoleDto in project xmall by Exrick.
the class UserServiceImpl method getRoleList.
@Override
public DataTablesResult getRoleList() {
DataTablesResult result = new DataTablesResult();
List<RoleDto> list = new ArrayList<>();
TbRoleExample example = new TbRoleExample();
List<TbRole> list1 = tbRoleMapper.selectByExample(example);
if (list1 == null) {
throw new XmallException("获取角色列表失败");
}
for (TbRole tbRole : list1) {
RoleDto roleDto = new RoleDto();
roleDto.setId(tbRole.getId());
roleDto.setName(tbRole.getName());
roleDto.setDescription(tbRole.getDescription());
List<String> permissions = tbUserMapper.getPermsByRoleId(tbRole.getId());
String names = "";
if (permissions.size() > 1) {
names += permissions.get(0);
for (int i = 1; i < permissions.size(); i++) {
names += "|" + permissions.get(i);
}
} else if (permissions.size() == 1) {
names += permissions.get(0);
}
roleDto.setPermissions(names);
list.add(roleDto);
}
result.setData(list);
return result;
}
Aggregations