Skip to content

Commit

Permalink
解决带父子关系时查看详情父对象long未转换为字符串的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
erupts committed May 27, 2024
1 parent a5e81a5 commit 38c5537
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 16 deletions.
10 changes: 8 additions & 2 deletions erupt-core/src/main/java/xyz/erupt/core/util/EruptUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ public static Map<String, Object> generateEruptDataMap(EruptModel eruptModel, Ob
label = referenceTableType.label();
}
Map<String, Object> referMap = new HashMap<>();
referMap.put(id, ReflectUtil.findFieldChain(id, value));
Object rid = ReflectUtil.findFieldChain(id, value);
if (null == rid) {
referMap.put(id, null);
} else {
referMap.put(id, rid.toString());
}
referMap.put(label, ReflectUtil.findFieldChain(label, value));
for (View view : eruptField.views()) {
//修复表格列无法显示子类属性(例如xxx.yyy.zzz这样的列配置)的缺陷,要配合前端的bug修复。
Expand All @@ -99,7 +104,7 @@ public static Map<String, Object> generateEruptDataMap(EruptModel eruptModel, Ob
case TAB_TREE:
EruptModel tabEruptModel = EruptCoreService.getErupt(fieldModel.getFieldReturnName());
Collection<?> collection = (Collection<?>) value;
if (collection.size() > 0) {
if (!collection.isEmpty()) {
Set<Object> idSet = new HashSet<>();
Field primaryField = ReflectUtil.findClassField(collection.iterator().next().getClass(),
tabEruptModel.getErupt().primaryKeyCol());
Expand All @@ -121,6 +126,7 @@ public static Map<String, Object> generateEruptDataMap(EruptModel eruptModel, Ob
break;
default:
if (fieldModel.getField().getType() == Long.class ||
fieldModel.getField().getType() == Float.class ||
fieldModel.getField().getType() == Double.class ||
fieldModel.getField().getType() == BigDecimal.class) {
map.put(field.getName(), value.toString());
Expand Down
17 changes: 3 additions & 14 deletions erupt-upms/src/main/java/xyz/erupt/upms/model/EruptUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import xyz.erupt.annotation.EruptField;
import xyz.erupt.annotation.EruptI18n;
import xyz.erupt.annotation.constant.AnnotationConst;
import xyz.erupt.annotation.fun.FilterHandler;
import xyz.erupt.annotation.sub_erupt.Filter;
import xyz.erupt.annotation.sub_erupt.LinkTree;
import xyz.erupt.annotation.sub_erupt.RowOperation;
Expand All @@ -18,16 +17,14 @@
import xyz.erupt.annotation.sub_field.sub_edit.InputType;
import xyz.erupt.annotation.sub_field.sub_edit.ReferenceTreeType;
import xyz.erupt.annotation.sub_field.sub_edit.Search;
import xyz.erupt.core.constant.MenuTypeEnum;
import xyz.erupt.core.constant.RegexConst;
import xyz.erupt.upms.looker.LookerSelf;
import xyz.erupt.upms.model.filter.EruptMenuViewFilter;
import xyz.erupt.upms.model.input.ResetPassword;
import xyz.erupt.upms.model.input.ResetPasswordExec;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;

/**
Expand All @@ -50,7 +47,7 @@
@EruptI18n
@Getter
@Setter
public class EruptUser extends LookerSelf implements FilterHandler {
public class EruptUser extends LookerSelf {

@Column(length = AnnotationConst.CODE_LENGTH, unique = true)
@EruptField(
Expand Down Expand Up @@ -105,7 +102,7 @@ public class EruptUser extends LookerSelf implements FilterHandler {
title = "首页菜单",
type = EditType.REFERENCE_TREE,
referenceTreeType = @ReferenceTreeType(pid = "parentMenu.id"),
filter = @Filter(conditionHandler = EruptUser.class)
filter = @Filter(conditionHandler = EruptMenuViewFilter.class)
)
)
private EruptMenu eruptMenu;
Expand Down Expand Up @@ -210,12 +207,4 @@ public EruptUser(Long id) {
this.setId(id);
}

@Override
public String filter(String condition, String[] params) {
List<String> nts = new ArrayList<>();
nts.add(MenuTypeEnum.API.getCode());
nts.add(MenuTypeEnum.BUTTON.getCode());
return String.format("EruptMenu.type not in ('%s') or EruptMenu.type is null", String.join("','", nts));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package xyz.erupt.upms.model.filter;

import xyz.erupt.annotation.fun.FilterHandler;
import xyz.erupt.core.constant.MenuTypeEnum;

import java.util.ArrayList;
import java.util.List;

/**
* @author YuePeng
* date 2024/5/27 21:39
*/
public class EruptMenuViewFilter implements FilterHandler {

@Override
public String filter(String condition, String[] params) {
List<String> nts = new ArrayList<>();
nts.add(MenuTypeEnum.API.getCode());
nts.add(MenuTypeEnum.BUTTON.getCode());
return String.format("EruptMenu.type not in ('%s') or EruptMenu.type is null", String.join("','", nts));
}

}

0 comments on commit 38c5537

Please sign in to comment.