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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations