@@ -457,4 +457,16 @@ public class KeycloakServiceImpl implements KeycloakService {
return PageResponse.of(userRepresentations ,0 ,0,0);
}
+
+ @Override
+ public List<String> queryWechatByRole(String role) {
+ List<String> openIds = Lists.newArrayList();
+ realmResource.roles().get(role).getRoleUserMembers().forEach(user->{
+ Map<String, List<String>> attributes = user.getAttributes();
+ if (attributes != null && attributes.get("wechat") != null) {
+ openIds.addAll(attributes.get("wechat"));
+ }
+ });
+ return openIds;
@@ -223,4 +223,11 @@ public interface KeycloakService {
*/
PageResponse<UserRepresentation> getUserListByIds(SmsbDepartmentCmd departmentCmd , List<String> userId);
+ /**
+ * 通过角色获取用户微信的openId
+ *
+ * @param role
+ * @return openId的集合
+ */
+ List<String> queryWechatByRole(String role);