java110
2022-09-19 cd8657e2dcffe17efd02cd055f8e6dfd6d703c96
java110-doc/src/main/java/com/java110/doc/registrar/Java110ApiDocDiscoveryRegistrar.java
@@ -12,6 +12,7 @@
import org.springframework.context.ResourceLoaderAware;
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.filter.AnnotationTypeFilter;
@@ -22,10 +23,7 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
/**
 * api 文档 注入类
@@ -98,7 +96,6 @@
                    AnnotatedBeanDefinition beanDefinition = (AnnotatedBeanDefinition) candidateComponent;
                    AnnotationMetadata annotationMetadata = beanDefinition.getMetadata();
                    Map<String, Object> attributes = annotationMetadata
                            .getAnnotationAttributes(
                                    Java110ApiDoc.class.getCanonicalName());
@@ -112,15 +109,21 @@
                            .getAnnotationAttributes(
                    Java110RequestMappingsDoc.class.getCanonicalName());
                    attributes.get("mappingsDocs");
                    AnnotationAttributes[] mappingAttrs = (AnnotationAttributes[])attributes.get("mappingsDocs");
                    List<RequestMappingsDocDto> mappingsDocDtos = new ArrayList<>();
                    RequestMappingsDocDto requestMappingsDocDto = null;
                    for(AnnotationAttributes mappingAttr : mappingAttrs){
                        requestMappingsDocDto = new RequestMappingsDocDto(mappingAttr.get("name").toString(),mappingAttr.get("resource").toString(),
                                Integer.parseInt(mappingAttr.get("seq").toString()),mappingAttr.get("url").toString(),mappingAttr.get("startWay").toString()
                                );
                        mappingsDocDtos.add(requestMappingsDocDto);
                    }
                    /*BeanDefinitionHolder definitionHolder = new BeanDefinitionHolder(beanDefinition, beanName);
                    BeanDefinitionReaderUtils.registerBeanDefinition(definitionHolder, registry);*/
                    Method method = cmdPublishClass.getMethod("setApiDoc", ApiDocDto.class, List.class);
                    method.invoke(null,apiDocDto,null);
                    method.invoke(null,apiDocDto,mappingsDocDtos);
                }
            }
        }