Search in sources :

Example 1 with SysUser

use of com.megagao.production.ssm.domain.authority.SysUser in project production_ssm by megagao.

the class UserServiceImpl method getList.

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

Example 2 with SysUser

use of com.megagao.production.ssm.domain.authority.SysUser in project production_ssm by megagao.

the class UserServiceImpl method searchUserByUserId.

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

Example 3 with SysUser

use of com.megagao.production.ssm.domain.authority.SysUser in project production_ssm by megagao.

the class UserServiceImpl method searchUserByRoleName.

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

Example 4 with SysUser

use of com.megagao.production.ssm.domain.authority.SysUser 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 5 with SysUser

use of com.megagao.production.ssm.domain.authority.SysUser in project production_ssm by megagao.

the class SysServiceImpl method getSysUserByName.

@Override
public SysUser getSysUserByName(String username) throws Exception {
    SysUserExample sysUserExample = new SysUserExample();
    SysUserExample.Criteria criteria = sysUserExample.createCriteria();
    criteria.andUsernameEqualTo(username);
    List<SysUser> list = sysUserMapper.selectByExample(sysUserExample);
    if (list != null && list.size() == 1) {
        return list.get(0);
    }
    return null;
}
Also used : SysUser(com.megagao.production.ssm.domain.authority.SysUser) SysUserExample(com.megagao.production.ssm.domain.authority.SysUserExample)

Aggregations

SysUser (com.megagao.production.ssm.domain.authority.SysUser)7 PageInfo (com.github.pagehelper.PageInfo)4 EUDataGridResult (com.megagao.production.ssm.domain.customize.EUDataGridResult)4 SysUserExample (com.megagao.production.ssm.domain.authority.SysUserExample)2 SysPermission (com.megagao.production.ssm.domain.authority.SysPermission)1 ActiveUser (com.megagao.production.ssm.domain.customize.ActiveUser)1 RoleVO (com.megagao.production.ssm.domain.vo.RoleVO)1 AuthenticationException (org.apache.shiro.authc.AuthenticationException)1 SimpleAuthenticationInfo (org.apache.shiro.authc.SimpleAuthenticationInfo)1