Search in sources :

Example 36 with UserInfo

use of com.ctrip.framework.apollo.portal.entity.bo.UserInfo in project apollo by ctripcorp.

the class DefaultRolePermissionService method queryUsersWithRole.

/**
 * Query users with role
 */
public Set<UserInfo> queryUsersWithRole(String roleName) {
    Role role = findRoleByRoleName(roleName);
    if (role == null) {
        return Collections.emptySet();
    }
    List<UserRole> userRoles = userRoleRepository.findByRoleId(role.getId());
    return userRoles.stream().map(userRole -> {
        UserInfo userInfo = new UserInfo();
        userInfo.setUserId(userRole.getUserId());
        return userInfo;
    }).collect(Collectors.toSet());
}
Also used : Role(com.ctrip.framework.apollo.portal.entity.po.Role) UserRole(com.ctrip.framework.apollo.portal.entity.po.UserRole) Date(java.util.Date) Role(com.ctrip.framework.apollo.portal.entity.po.Role) Autowired(org.springframework.beans.factory.annotation.Autowired) Multimap(com.google.common.collect.Multimap) Permission(com.ctrip.framework.apollo.portal.entity.po.Permission) UserInfo(com.ctrip.framework.apollo.portal.entity.bo.UserInfo) HashMultimap(com.google.common.collect.HashMultimap) Lists(com.google.common.collect.Lists) StreamSupport(java.util.stream.StreamSupport) RolePermissionService(com.ctrip.framework.apollo.portal.service.RolePermissionService) UserRole(com.ctrip.framework.apollo.portal.entity.po.UserRole) PortalConfig(com.ctrip.framework.apollo.portal.component.config.PortalConfig) RolePermission(com.ctrip.framework.apollo.portal.entity.po.RolePermission) Collection(java.util.Collection) Set(java.util.Set) ConsumerRoleRepository(com.ctrip.framework.apollo.openapi.repository.ConsumerRoleRepository) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) List(java.util.List) UserRoleRepository(com.ctrip.framework.apollo.portal.repository.UserRoleRepository) RolePermissionRepository(com.ctrip.framework.apollo.portal.repository.RolePermissionRepository) PermissionRepository(com.ctrip.framework.apollo.portal.repository.PermissionRepository) CollectionUtils(org.springframework.util.CollectionUtils) Preconditions(com.google.common.base.Preconditions) RoleRepository(com.ctrip.framework.apollo.portal.repository.RoleRepository) Collections(java.util.Collections) Transactional(org.springframework.transaction.annotation.Transactional) UserRole(com.ctrip.framework.apollo.portal.entity.po.UserRole) UserInfo(com.ctrip.framework.apollo.portal.entity.bo.UserInfo)

Aggregations

UserInfo (com.ctrip.framework.apollo.portal.entity.bo.UserInfo)36 AbstractUnitTest (com.ctrip.framework.apollo.portal.AbstractUnitTest)7 Test (org.junit.Test)7 BadRequestException (com.ctrip.framework.apollo.common.exception.BadRequestException)6 ItemChangeSets (com.ctrip.framework.apollo.common.dto.ItemChangeSets)3 ItemDTO (com.ctrip.framework.apollo.common.dto.ItemDTO)3 NamespaceDTO (com.ctrip.framework.apollo.common.dto.NamespaceDTO)3 App (com.ctrip.framework.apollo.common.entity.App)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Consumer (com.ctrip.framework.apollo.openapi.entity.Consumer)2 Role (com.ctrip.framework.apollo.portal.entity.po.Role)2 ItemDiffs (com.ctrip.framework.apollo.portal.entity.vo.ItemDiffs)2 NamespaceIdentifier (com.ctrip.framework.apollo.portal.entity.vo.NamespaceIdentifier)2 Sets (com.google.common.collect.Sets)2 Collections (java.util.Collections)2 Set (java.util.Set)2 DirContextAdapter (org.springframework.ldap.core.DirContextAdapter)2 Transactional (org.springframework.transaction.annotation.Transactional)2 ClusterDTO (com.ctrip.framework.apollo.common.dto.ClusterDTO)1