提交 16502eda authored 作者: 黄承天's avatar 黄承天

[数据模型]修正描述信息问题

上级 c42911a4
...@@ -20,7 +20,6 @@ import java.util.*; ...@@ -20,7 +20,6 @@ import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static java.lang.String.format; import static java.lang.String.format;
import static java.util.Objects.isNull;
import static java.util.Objects.nonNull; import static java.util.Objects.nonNull;
@Slf4j @Slf4j
...@@ -67,14 +66,14 @@ public class ApiService { ...@@ -67,14 +66,14 @@ public class ApiService {
//确认CallableApi注解 //确认CallableApi注解
if (method.isAnnotationPresent(CallableApi.class)) { if (method.isAnnotationPresent(CallableApi.class)) {
List<EntityInfo> params = Arrays.stream(method.getParameters()) List<EntityInfo> params = Arrays.stream(method.getParameters())
.map(parameter -> entityInfo(parameter.getType(), parameter.getName(), Strings.EMPTY)) .map(parameter -> entityInfo(parameter.getType(), parameter.getName()))
.collect(Collectors.toList()); .collect(Collectors.toList());
Class<?> returnType = method.getReturnType(); Class<?> returnType = method.getReturnType();
EntityInfo ret = entityInfo(returnType, Strings.EMPTY, Strings.EMPTY); EntityInfo ret = entityInfo(returnType, Strings.EMPTY);
ApiOperation methodAnnotation = method.getAnnotation(ApiOperation.class); ApiOperation methodAnnotation = method.getAnnotation(ApiOperation.class);
String description = Strings.EMPTY; String description = Strings.EMPTY;
if (nonNull(methodAnnotation)) { if (nonNull(methodAnnotation)) {
description = methodAnnotation.notes(); description = methodAnnotation.value();
} }
return new ApiInfo(className, method.getName(), params, ret, description); return new ApiInfo(className, method.getName(), params, ret, description);
} else { } else {
...@@ -82,9 +81,10 @@ public class ApiService { ...@@ -82,9 +81,10 @@ public class ApiService {
} }
} }
private EntityInfo entityInfo(Class<?> clz, String name, String description) { private EntityInfo entityInfo(Class<?> clz, String name) {
String classType = clz.getCanonicalName(); String classType = clz.getCanonicalName();
List<EntityInfo> fields = new ArrayList<>(); List<EntityInfo> fields = new ArrayList<>();
String description = Strings.EMPTY;
if (isNotBasicClass(clz)) { if (isNotBasicClass(clz)) {
for (Field field : clz.getDeclaredFields()) { for (Field field : clz.getDeclaredFields()) {
Class<?> fieldClass = field.getType(); Class<?> fieldClass = field.getType();
...@@ -99,7 +99,7 @@ public class ApiService { ...@@ -99,7 +99,7 @@ public class ApiService {
boolean isDifferentClass = !Objects.equals(clz, fieldClass); boolean isDifferentClass = !Objects.equals(clz, fieldClass);
EntityInfo fieldClassInfo; EntityInfo fieldClassInfo;
if (isDifferentClass) { if (isDifferentClass) {
fieldClassInfo = entityInfo(fieldClass, fieldName, description); fieldClassInfo = entityInfo(fieldClass, fieldName);
} else { } else {
fieldClassInfo = new EntityInfo(fieldClass.getSimpleName(), field.getName(), new ArrayList<>(), description); fieldClassInfo = new EntityInfo(fieldClass.getSimpleName(), field.getName(), new ArrayList<>(), description);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论