Przeglądaj źródła

fix:添加获取aiAudit列表

wangbo 3 lat temu
rodzic
commit
305f9ef182

+ 16 - 0
smsb-customer-manager-app/src/main/java/com/inspur/customer/service/keycloak/KeycloakServiceImpl.java

@@ -11,10 +11,12 @@ import org.keycloak.representations.idm.RoleRepresentation;
 import org.keycloak.representations.idm.UserRepresentation;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.cache.annotation.Cacheable;
+import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicReference;
+import java.util.stream.Collectors;
 
 @Slf4j
 @DubboService
@@ -126,4 +128,18 @@ public class KeycloakServiceImpl implements KeycloakService {
         return Collections.emptyList();
     }
 
+    @Override
+    public List<String> getAiAuditList() {
+        List<GroupRepresentation> groups = keycloak.realm(realm).groups().groups();
+        List<String> aiAudit = groups.stream().filter(groupRepresentation -> {
+            Map<String, List<String>> attributes = groupRepresentation.getAttributes();
+            if (attributes != null) {
+                List<String> list = attributes.get("aiAudit");
+                return !CollectionUtils.isEmpty(list) && "1".equals(list.get(0));
+            }
+            return false;
+        }).map(GroupRepresentation::getPath).collect(Collectors.toList());
+        return aiAudit;
+    }
+
 }

+ 7 - 0
smsb-customer-manager-client/src/main/java/com/inspur/customer/service/client/keycloak/KeycloakService.java

@@ -46,4 +46,11 @@ public interface KeycloakService {
      * @return
      */
     List<String> getAttrByGroupPath(String groupPath, String key);
+
+    /**
+     * getAiAuditList
+     *
+     * @return
+     */
+    List<String> getAiAuditList();
 }