use of com.zyd.blog.business.entity.Role in project OneBlog by zhangyd-c.
the class SysRoleServiceImpl method insertList.
@Override
public void insertList(List<Role> entities) {
Assert.notNull(entities, "entities不可为空!");
List<SysRole> sysRole = new ArrayList<>();
for (Role role : entities) {
role.setUpdateTime(new Date());
role.setCreateTime(new Date());
sysRole.add(role.getSysRole());
}
roleMapper.insertList(sysRole);
}
use of com.zyd.blog.business.entity.Role in project OneBlog by zhangyd-c.
the class ShiroRealm method doGetAuthorizationInfo.
/**
* 权限认证,为当前登录的Subject授予角色和权限(角色的权限信息集合)
*/
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {
// 权限信息对象info,用来存放查出的用户的所有的角色(role)及权限(permission)
SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
Long userId = (Long) SecurityUtils.getSubject().getPrincipal();
// 赋予角色
List<Role> roleList = roleService.listRolesByUserId(userId);
if (null != roleList) {
for (Role role : roleList) {
info.addRole(role.getName());
}
}
// 赋予权限
List<Resources> resourcesList = null;
User user = userService.getByPrimaryKey(userId);
if (null == user) {
return info;
}
// ROOT用户默认拥有所有权限
if (UserTypeEnum.ROOT.toString().equalsIgnoreCase(user.getUserType())) {
resourcesList = resourcesService.listAll();
} else {
resourcesList = resourcesService.listByUserId(userId);
}
if (!CollectionUtils.isEmpty(resourcesList)) {
Set<String> permissionSet = new HashSet<>();
for (Resources resources : resourcesList) {
String permission = null;
if (!StringUtils.isEmpty(permission = resources.getPermission())) {
permissionSet.addAll(Arrays.asList(permission.trim().split(",")));
}
}
info.setStringPermissions(permissionSet);
}
return info;
}
use of com.zyd.blog.business.entity.Role in project OneBlog by zhangyd-c.
the class SysRoleServiceImpl method getByPrimaryKey.
@Override
public Role getByPrimaryKey(Long primaryKey) {
Assert.notNull(primaryKey, "PrimaryKey不可为空!");
SysRole sysRole = roleMapper.selectByPrimaryKey(primaryKey);
return null == sysRole ? null : new Role(sysRole);
}
use of com.zyd.blog.business.entity.Role in project OneBlog by zhangyd-c.
the class SysRoleServiceImpl method findPageBreakByCondition.
@Override
public PageInfo<Role> findPageBreakByCondition(RoleConditionVO vo) {
PageHelper.startPage(vo.getPageNumber(), vo.getPageSize());
List<SysRole> sysRoles = roleMapper.findPageBreakByCondition(vo);
if (CollectionUtils.isEmpty(sysRoles)) {
return null;
}
List<Role> roles = this.getRole(sysRoles);
PageInfo bean = new PageInfo<SysRole>(sysRoles);
bean.setList(roles);
return bean;
}
Aggregations