mirror of https://gitee.com/stylefeng/roses
修改类型判断
parent
d40af1f6d7
commit
25c393f0fd
|
@ -44,7 +44,7 @@ import java.util.*;
|
||||||
*/
|
*/
|
||||||
public class ClassReflectUtil {
|
public class ClassReflectUtil {
|
||||||
|
|
||||||
private static Map<String, String> runingMap = new HashMap<>(2);
|
private static Map<String, String> runMap = new HashMap<>(2);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取一个类的所有字段描述
|
* 获取一个类的所有字段描述
|
||||||
|
@ -62,7 +62,7 @@ public class ClassReflectUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询本类是否正在进行解析(防止死循环)
|
// 查询本类是否正在进行解析(防止死循环)
|
||||||
String runing = runingMap.get(clazz.getName());
|
String runing = runMap.get(clazz.getName());
|
||||||
|
|
||||||
// 返回null则标识这个类正在运行,则不对该类再进行解析
|
// 返回null则标识这个类正在运行,则不对该类再进行解析
|
||||||
if (ObjectUtil.isNotEmpty(runing)) {
|
if (ObjectUtil.isNotEmpty(runing)) {
|
||||||
|
@ -71,7 +71,7 @@ public class ClassReflectUtil {
|
||||||
|
|
||||||
// 获取该类和该类所有父类的属性
|
// 获取该类和该类所有父类的属性
|
||||||
while (clazz != null) {
|
while (clazz != null) {
|
||||||
runingMap.put(clazz.getName(), clazz.getName());
|
runMap.put(clazz.getName(), clazz.getName());
|
||||||
// 获取类中的所有字段
|
// 获取类中的所有字段
|
||||||
Field[] declaredFields = ClassUtil.getDeclaredFields(clazz);
|
Field[] declaredFields = ClassUtil.getDeclaredFields(clazz);
|
||||||
for (Field declaredField : declaredFields) {
|
for (Field declaredField : declaredFields) {
|
||||||
|
@ -80,7 +80,7 @@ public class ClassReflectUtil {
|
||||||
fieldDescriptions.add(fieldDescription);
|
fieldDescriptions.add(fieldDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
runingMap.remove(clazz.getName());
|
runMap.remove(clazz.getName());
|
||||||
// 获取本类的父类
|
// 获取本类的父类
|
||||||
clazz = clazz.getSuperclass();
|
clazz = clazz.getSuperclass();
|
||||||
}
|
}
|
||||||
|
|
|
@ -415,14 +415,14 @@ public class ApiResourceServiceImpl extends ServiceImpl<ApiResourceMapper, ApiRe
|
||||||
item.setApiResourceId(apiResourceId);
|
item.setApiResourceId(apiResourceId);
|
||||||
item.setFieldCode(fieldMetadata.getFieldName());
|
item.setFieldCode(fieldMetadata.getFieldName());
|
||||||
item.setFieldName(fieldMetadata.getChineseName());
|
item.setFieldName(fieldMetadata.getChineseName());
|
||||||
if ("cn.stylefeng.".contains(fieldMetadata.getFieldClassPath())) {
|
if (fieldMetadata.getFieldClassPath().contains("java.util")) {
|
||||||
item.setFieldType("object");
|
|
||||||
} else if ("java.util".contains(fieldMetadata.getFieldClassPath())) {
|
|
||||||
item.setFieldType("list");
|
item.setFieldType("list");
|
||||||
} else if ("java.io".contains(fieldMetadata.getFieldClassPath())) {
|
} else if (fieldMetadata.getFieldClassPath().contains("java.io")) {
|
||||||
item.setFieldType("file");
|
item.setFieldType("file");
|
||||||
} else {
|
} else if (fieldMetadata.getFieldClassPath().contains("java.")) {
|
||||||
item.setFieldType("string");
|
item.setFieldType("string");
|
||||||
|
} else {
|
||||||
|
item.setFieldType("object");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 是否必填
|
// 是否必填
|
||||||
|
@ -437,6 +437,10 @@ public class ApiResourceServiceImpl extends ServiceImpl<ApiResourceMapper, ApiRe
|
||||||
Set<ApiResourceField> apiResourceFieldSet = new HashSet<>();
|
Set<ApiResourceField> apiResourceFieldSet = new HashSet<>();
|
||||||
for (FieldMetadata genericFieldMetadatum : genericFieldMetadata) {
|
for (FieldMetadata genericFieldMetadatum : genericFieldMetadata) {
|
||||||
ApiResourceField conversion = this.conversion(sysResource, apiResourceId, genericFieldMetadatum);
|
ApiResourceField conversion = this.conversion(sysResource, apiResourceId, genericFieldMetadatum);
|
||||||
|
// 如果是list设置嵌套类型里面的全是非必填
|
||||||
|
if ("list".equals(item.getFieldType())) {
|
||||||
|
conversion.setFieldRequired(YesOrNotEnum.N.getCode());
|
||||||
|
}
|
||||||
apiResourceFieldSet.add(conversion);
|
apiResourceFieldSet.add(conversion);
|
||||||
}
|
}
|
||||||
item.setFieldSubInfo(JSON.toJSONString(apiResourceFieldSet, SerializerFeature.WriteClassName));
|
item.setFieldSubInfo(JSON.toJSONString(apiResourceFieldSet, SerializerFeature.WriteClassName));
|
||||||
|
|
Loading…
Reference in New Issue