From 907bf1cbfb1051854a26a28a5357e7b02a032091 Mon Sep 17 00:00:00 2001 From: shalousun Date: Sat, 15 May 2021 22:30:04 +0800 Subject: [PATCH] fix gitee #I3RGQL . --- CHANGELOG.md | 1 + .../power/doc/template/SpringBootDocBuildTemplate.java | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 83d58eb..9eebea2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - 更新内容: 1. 修复推送接口到torna丢失部分mock值的问题。 2. 修复在参数注释中配置类替换时将非类名解析成类名的bug 。 + 3. 支持父类上加@RestController注解的子类能够被识别和扫描 #### 版本号:2.1.7 - 更新日期: 2020-05-12 - 更新内容: diff --git a/src/main/java/com/power/doc/template/SpringBootDocBuildTemplate.java b/src/main/java/com/power/doc/template/SpringBootDocBuildTemplate.java index 37e505e..b5fd553 100644 --- a/src/main/java/com/power/doc/template/SpringBootDocBuildTemplate.java +++ b/src/main/java/com/power/doc/template/SpringBootDocBuildTemplate.java @@ -825,7 +825,10 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate { } private boolean checkController(JavaClass cls) { - List classAnnotations = cls.getAnnotations(); + JavaClass superClass = cls.getSuperJavaClass(); + List classAnnotations = new ArrayList<>(); + classAnnotations.addAll(superClass.getAnnotations()); + classAnnotations.addAll(cls.getAnnotations()); for (JavaAnnotation annotation : classAnnotations) { String name = annotation.getType().getValue(); if (SpringMvcAnnotations.CONTROLLER.equals(name) || SpringMvcAnnotations.REST_CONTROLLER.equals(name)) { @@ -912,7 +915,8 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate { } private List getAnnotations(JavaClass cls) { - List annotationsList = cls.getAnnotations(); + List annotationsList = new ArrayList<>(); + annotationsList.addAll(cls.getAnnotations()); boolean flag = annotationsList.stream().anyMatch(item -> { String annotationName = item.getType().getValue(); if (DocAnnotationConstants.REQUEST_MAPPING.equals(annotationName) ||