Search in sources :

Example 1 with RoleDto

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;
}
Also used : RoleDto(cn.exrick.manager.dto.RoleDto) DataTablesResult(cn.exrick.common.pojo.DataTablesResult) XmallException(cn.exrick.common.exception.XmallException)

Aggregations

XmallException (cn.exrick.common.exception.XmallException)1 DataTablesResult (cn.exrick.common.pojo.DataTablesResult)1 RoleDto (cn.exrick.manager.dto.RoleDto)1