修复代码生成器,父类错误的bug
This commit is contained in:
+9
-4
@@ -207,7 +207,6 @@ public class QueryGenerator {
|
|||||||
if (parameterMap != null && parameterMap.containsKey(filedName + BEGIN)) {
|
if (parameterMap != null && parameterMap.containsKey(filedName + BEGIN)) {
|
||||||
beginValue = parameterMap.get(filedName + BEGIN)[0].trim();
|
beginValue = parameterMap.get(filedName + BEGIN)[0].trim();
|
||||||
addQueryByRule(queryWrapper, columnName, type, beginValue, QueryRuleEnum.GE);
|
addQueryByRule(queryWrapper, columnName, type, beginValue, QueryRuleEnum.GE);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (parameterMap != null && parameterMap.containsKey(filedName + END)) {
|
if (parameterMap != null && parameterMap.containsKey(filedName + END)) {
|
||||||
endValue = parameterMap.get(filedName + END)[0].trim();
|
endValue = parameterMap.get(filedName + END)[0].trim();
|
||||||
@@ -1075,12 +1074,18 @@ public class QueryGenerator {
|
|||||||
private static String getTableFieldName(Class<?> clazz, String name) {
|
private static String getTableFieldName(Class<?> clazz, String name) {
|
||||||
try {
|
try {
|
||||||
//如果字段加注解了@TableField(exist = false),不走DB查询
|
//如果字段加注解了@TableField(exist = false),不走DB查询
|
||||||
Field field = clazz.getDeclaredField(name);
|
Field field = null;
|
||||||
|
try {
|
||||||
|
field = clazz.getDeclaredField(name);
|
||||||
|
} catch (NoSuchFieldException e) {
|
||||||
|
log.error("{}字段无法在当前类找到,将在父类寻找", name);
|
||||||
|
}
|
||||||
|
|
||||||
//如果为空,则去父类查找字段
|
//如果为空,则去父类查找字段
|
||||||
if (field == null) {
|
if (field == null) {
|
||||||
List<Field> allFields = getClassFields(clazz);
|
List<Field> allFields = getClassFields(clazz);
|
||||||
List<Field> searchFields = allFields.stream().filter(a -> a.getName().equals(name)).collect(Collectors.toList());
|
List<Field> searchFields = allFields.stream().filter(a -> a.getName().equals(name)).collect(Collectors.toList());
|
||||||
if(!CollectionUtils.isEmpty(searchFields)){
|
if(searchFields!=null && searchFields.size()>0){
|
||||||
field = searchFields.get(0);
|
field = searchFields.get(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1088,7 +1093,7 @@ public class QueryGenerator {
|
|||||||
if (field != null) {
|
if (field != null) {
|
||||||
TableField tableField = field.getAnnotation(TableField.class);
|
TableField tableField = field.getAnnotation(TableField.class);
|
||||||
if (tableField != null){
|
if (tableField != null){
|
||||||
if(!tableField.exist()){
|
if(tableField.exist() == false){
|
||||||
//如果设置了TableField false 这个字段不需要处理
|
//如果设置了TableField false 这个字段不需要处理
|
||||||
return null;
|
return null;
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
Reference in New Issue
Block a user