Search in sources :

Example 21 with DataTablesResult

use of cn.exrick.common.pojo.DataTablesResult 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

DataTablesResult (cn.exrick.common.pojo.DataTablesResult)21 XmallException (cn.exrick.common.exception.XmallException)11 PageInfo (com.github.pagehelper.PageInfo)5 ApiOperation (io.swagger.annotations.ApiOperation)5 TbItem (cn.exrick.manager.pojo.TbItem)2 TbMember (cn.exrick.manager.pojo.TbMember)2 TbMemberExample (cn.exrick.manager.pojo.TbMemberExample)2 TbThanks (cn.exrick.manager.pojo.TbThanks)2 TbThanksExample (cn.exrick.manager.pojo.TbThanksExample)2 ArrayList (java.util.ArrayList)2 ContentDto (cn.exrick.manager.dto.ContentDto)1 ImageDto (cn.exrick.manager.dto.ImageDto)1 RoleDto (cn.exrick.manager.dto.RoleDto)1 TbContentCategory (cn.exrick.manager.pojo.TbContentCategory)1 TbImage (cn.exrick.manager.pojo.TbImage)1 TbImageExample (cn.exrick.manager.pojo.TbImageExample)1 TbItemExample (cn.exrick.manager.pojo.TbItemExample)1 TbShiroFilter (cn.exrick.manager.pojo.TbShiroFilter)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1