Fix su entityHierachy
This commit is contained in:
@@ -11,6 +11,7 @@ public class EntityHierarchyDTO {
|
||||
private String entityName;
|
||||
private String tableName;
|
||||
private Field field;
|
||||
private boolean master;
|
||||
private List<EntityHierarchyDTO> children;
|
||||
|
||||
public Class<? extends EntityBase> getClazz() {
|
||||
@@ -47,6 +48,15 @@ public class EntityHierarchyDTO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isMaster() {
|
||||
return master;
|
||||
}
|
||||
|
||||
public EntityHierarchyDTO setMaster(boolean master) {
|
||||
this.master = master;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<EntityHierarchyDTO> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
@@ -80,15 +80,18 @@ public class EntityPropertyHolder {
|
||||
Reflections reflections = new Reflections("it.integry.ems_model.entity");
|
||||
List<EntityHierarchyDTO> mapping = new ArrayList<>();
|
||||
Set<Class<? extends EntityBase>> classes = reflections.getSubTypesOf(EntityBase.class);
|
||||
|
||||
for (Class<? extends EntityBase> entity : classes) {
|
||||
if (entity.isAnnotationPresent(Master.class)) {
|
||||
EntityHierarchyDTO dto = new EntityHierarchyDTO();
|
||||
dto.setClazz(entity);
|
||||
dto.setEntityName(entity.getSimpleName());
|
||||
dto.setTableName(entity.getAnnotation(Table.class).value());
|
||||
dto.setChildren(getEntityChildren(entity));
|
||||
mapping.add(dto);
|
||||
}
|
||||
if(!entity.isAnnotationPresent(Table.class)) continue;
|
||||
|
||||
EntityHierarchyDTO dto = new EntityHierarchyDTO();
|
||||
dto.setClazz(entity);
|
||||
dto.setEntityName(entity.getSimpleName());
|
||||
dto.setTableName(entity.getAnnotation(Table.class).value());
|
||||
dto.setChildren(getEntityChildren(entity));
|
||||
dto.setMaster(entity.isAnnotationPresent(Master.class));
|
||||
|
||||
mapping.add(dto);
|
||||
}
|
||||
return mapping;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user