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