未验证 提交 9deb531e 编写于 作者: J Jason Song 提交者: GitHub

Merge pull request #1283 from nobodyiam/fix-spring-security-find-users

implement find users for spring security user service
...@@ -16,4 +16,6 @@ public interface UserRepository extends PagingAndSortingRepository<UserPO, Long> ...@@ -16,4 +16,6 @@ public interface UserRepository extends PagingAndSortingRepository<UserPO, Long>
List<UserPO> findByUsernameLikeAndEnabled(String username, int enabled); List<UserPO> findByUsernameLikeAndEnabled(String username, int enabled);
UserPO findByUsername(String username); UserPO findByUsername(String username);
List<UserPO> findByUsernameIn(List<String> userNames);
} }
...@@ -8,6 +8,7 @@ import com.ctrip.framework.apollo.portal.entity.po.UserPO; ...@@ -8,6 +8,7 @@ import com.ctrip.framework.apollo.portal.entity.po.UserPO;
import com.ctrip.framework.apollo.portal.repository.UserRepository; import com.ctrip.framework.apollo.portal.repository.UserRepository;
import com.ctrip.framework.apollo.portal.spi.UserService; import com.ctrip.framework.apollo.portal.spi.UserService;
import java.util.Collections;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority;
...@@ -88,7 +89,17 @@ public class SpringSecurityUserService implements UserService { ...@@ -88,7 +89,17 @@ public class SpringSecurityUserService implements UserService {
@Override @Override
public List<UserInfo> findByUserIds(List<String> userIds) { public List<UserInfo> findByUserIds(List<String> userIds) {
return null; List<UserPO> users = userRepository.findByUsernameIn(userIds);
if (CollectionUtils.isEmpty(users)) {
return Collections.emptyList();
}
List<UserInfo> result = Lists.newArrayList();
result.addAll(users.stream().map(UserPO::toUserInfo).collect(Collectors.toList()));
return result;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册