Search in sources :

Example 1 with RoleVO

use of com.megagao.production.ssm.domain.vo.RoleVO in project production_ssm by megagao.

the class RoleServiceImpl method searchRoleByRoleName.

@Override
public EUDataGridResult searchRoleByRoleName(Integer page, Integer rows, String roleName) throws Exception {
    // 分页处理
    PageHelper.startPage(page, rows);
    List<RoleVO> list = sysRoleMapper.searchRoleByRoleName(roleName);
    // 创建一个返回值对象
    EUDataGridResult result = new EUDataGridResult();
    result.setRows(list);
    // 取记录总条数
    PageInfo<RoleVO> pageInfo = new PageInfo<>(list);
    result.setTotal(pageInfo.getTotal());
    return result;
}
Also used : PageInfo(com.github.pagehelper.PageInfo) RoleVO(com.megagao.production.ssm.domain.vo.RoleVO) EUDataGridResult(com.megagao.production.ssm.domain.customize.EUDataGridResult)

Example 2 with RoleVO

use of com.megagao.production.ssm.domain.vo.RoleVO in project production_ssm by megagao.

the class CustomRealm method doGetAuthenticationInfo.

/**
 * realm的认证方法,从数据库查询用户信息
 */
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
    // token是用户输入的用户名和密码,第一步从token中取出用户名
    String username = (String) token.getPrincipal();
    // 第二步:根据用户输入的username从数据库查询
    SysUser sysUser = null;
    try {
        sysUser = sysService.getSysUserByName(username);
    } catch (Exception e) {
        logger.error(e.getMessage());
    }
    // 如果查询不到返回null
    if (sysUser == null) {
        if (logger.isDebugEnabled()) {
            logger.debug("user not exist!");
        }
        return null;
    }
    String password = sysUser.getPassword();
    // 如果查询到返回认证信息AuthenticationInfo
    // activeUser就是用户身份信息
    ActiveUser activeUser = new ActiveUser();
    activeUser.setUserid(sysUser.getId());
    activeUser.setUsername(sysUser.getUsername());
    activeUser.setUserStatus(sysUser.getLocked());
    RoleVO sysRole = null;
    try {
        sysRole = roleService.findRoleByUserId(sysUser.getId());
    } catch (Exception e) {
        logger.error(e.getMessage());
    }
    activeUser.setRolename(sysRole.getRoleName());
    activeUser.setRoleStatus(sysRole.getAvailable());
    logger.info(activeUser.getUsername());
    // 根据用户id取出菜单
    List<SysPermission> menus = null;
    try {
        // 通过service取出菜单
        menus = sysService.findMenuListByUserId(sysUser.getId());
    } catch (Exception e) {
        logger.error(e.getMessage());
    }
    // 将用户菜单设置到activeUser
    activeUser.setMenus(menus);
    // ByteSource q = ByteSource.Util.bytes(sysUser.getSalt());
    // 将activeUser设置simpleAuthenticationInfo
    SimpleAuthenticationInfo simpleAuthenticationInfo = new SimpleAuthenticationInfo(activeUser, password, this.getName());
    return simpleAuthenticationInfo;
}
Also used : RoleVO(com.megagao.production.ssm.domain.vo.RoleVO) SysUser(com.megagao.production.ssm.domain.authority.SysUser) SimpleAuthenticationInfo(org.apache.shiro.authc.SimpleAuthenticationInfo) ActiveUser(com.megagao.production.ssm.domain.customize.ActiveUser) SysPermission(com.megagao.production.ssm.domain.authority.SysPermission) AuthenticationException(org.apache.shiro.authc.AuthenticationException)

Example 3 with RoleVO

use of com.megagao.production.ssm.domain.vo.RoleVO in project production_ssm by megagao.

the class RoleServiceImpl method getList.

@Override
public EUDataGridResult getList(int page, int rows, RoleVO sysRole) throws Exception {
    // 查询列表
    SysRoleExample example = new SysRoleExample();
    // 分页处理
    PageHelper.startPage(page, rows);
    List<RoleVO> list = sysRoleMapper.selectByExample(example);
    // 创建一个返回值对象
    EUDataGridResult result = new EUDataGridResult();
    result.setRows(list);
    // 取记录总条数
    PageInfo<RoleVO> pageInfo = new PageInfo<>(list);
    result.setTotal(pageInfo.getTotal());
    return result;
}
Also used : PageInfo(com.github.pagehelper.PageInfo) RoleVO(com.megagao.production.ssm.domain.vo.RoleVO) SysRoleExample(com.megagao.production.ssm.domain.authority.SysRoleExample) EUDataGridResult(com.megagao.production.ssm.domain.customize.EUDataGridResult)

Example 4 with RoleVO

use of com.megagao.production.ssm.domain.vo.RoleVO in project production_ssm by megagao.

the class RoleServiceImpl method searchRoleByRoleId.

@Override
public EUDataGridResult searchRoleByRoleId(Integer page, Integer rows, String roleId) throws Exception {
    // 分页处理
    PageHelper.startPage(page, rows);
    List<RoleVO> list = sysRoleMapper.searchRoleByRoleId(roleId);
    // 创建一个返回值对象
    EUDataGridResult result = new EUDataGridResult();
    result.setRows(list);
    // 取记录总条数
    PageInfo<RoleVO> pageInfo = new PageInfo<>(list);
    result.setTotal(pageInfo.getTotal());
    return result;
}
Also used : PageInfo(com.github.pagehelper.PageInfo) RoleVO(com.megagao.production.ssm.domain.vo.RoleVO) EUDataGridResult(com.megagao.production.ssm.domain.customize.EUDataGridResult)

Example 5 with RoleVO

use of com.megagao.production.ssm.domain.vo.RoleVO in project production_ssm by megagao.

the class RoleServiceImpl method findRoleByUserId.

@Override
public RoleVO findRoleByUserId(String userId) throws Exception {
    SysUserRoleExample example = new SysUserRoleExample();
    SysUserRoleExample.Criteria criteria = example.createCriteria();
    criteria.andSysUserIdEqualTo(userId);
    SysUserRole sysUserRole = sysUserRoleMapper.selectByExample(example).get(0);
    RoleVO sysRole = sysRoleMapper.selectByPrimaryKey(sysUserRole.getSysRoleId());
    return sysRole;
}
Also used : RoleVO(com.megagao.production.ssm.domain.vo.RoleVO) SysUserRoleExample(com.megagao.production.ssm.domain.authority.SysUserRoleExample) SysUserRole(com.megagao.production.ssm.domain.authority.SysUserRole)

Aggregations

RoleVO (com.megagao.production.ssm.domain.vo.RoleVO)6 PageInfo (com.github.pagehelper.PageInfo)3 EUDataGridResult (com.megagao.production.ssm.domain.customize.EUDataGridResult)3 SysRoleExample (com.megagao.production.ssm.domain.authority.SysRoleExample)2 SysPermission (com.megagao.production.ssm.domain.authority.SysPermission)1 SysUser (com.megagao.production.ssm.domain.authority.SysUser)1 SysUserRole (com.megagao.production.ssm.domain.authority.SysUserRole)1 SysUserRoleExample (com.megagao.production.ssm.domain.authority.SysUserRoleExample)1 ActiveUser (com.megagao.production.ssm.domain.customize.ActiveUser)1 AuthenticationException (org.apache.shiro.authc.AuthenticationException)1 SimpleAuthenticationInfo (org.apache.shiro.authc.SimpleAuthenticationInfo)1