提交 ec23cadb 编写于 作者: tangyaologin's avatar tangyaologin

通过点击实体生成相应模型 第二版

上级 8e338395
...@@ -118,7 +118,8 @@ public class MetaEntityExService extends MetaEntityServiceImpl { ...@@ -118,7 +118,8 @@ public class MetaEntityExService extends MetaEntityServiceImpl {
*/ */
public LinkedHashSet<Property> findParRelation(MetaEntity et) { public LinkedHashSet<Property> findParRelation(MetaEntity et) {
Property property; Property property;
List<MetaEntity> parEntityList; Property temp;
MetaEntity parEntity;
PropertyMapping propertyMapping; PropertyMapping propertyMapping;
LinkedHashSet<PropertyMapping> propertyMappingSet; LinkedHashSet<PropertyMapping> propertyMappingSet;
LinkedHashSet<Property> parPropertyList = new LinkedHashSet<>(); LinkedHashSet<Property> parPropertyList = new LinkedHashSet<>();
...@@ -127,27 +128,33 @@ public class MetaEntityExService extends MetaEntityServiceImpl { ...@@ -127,27 +128,33 @@ public class MetaEntityExService extends MetaEntityServiceImpl {
List<MetaRelationship> parList = metaRelationshipService.selectByEntityId(et.getEntityId()); List<MetaRelationship> parList = metaRelationshipService.selectByEntityId(et.getEntityId());
if (!ObjectUtils.isEmpty(parList)) { if (!ObjectUtils.isEmpty(parList)) {
List<String> refIds = parList.stream().map(MetaRelationship::getRefEntityId).collect(Collectors.toList()); List<String> refIds = parList.stream().map(MetaRelationship::getRefEntityId).collect(Collectors.toList());
parEntityList = baseMapper.selectBatchIds(refIds); for (int i = 0; i < refIds.size(); i++) {
for (int i = 0; i < parEntityList.size(); i++) { parEntity = baseMapper.selectById(refIds.get(i));
// 存储对象参数集合 // 存储对象参数集合
property = new Property(); property = new Property();
propertyMapping = new PropertyMapping(); propertyMapping = new PropertyMapping();
property.setPropertyName(parEntityList.get(i).getEntityName() == null ? "" : parEntityList.get(i).getEntityName()); property.setPropertyName(parEntity.getEntityName() == null ? "" : parEntity.getEntityName());
property.setSystem(parEntityList.get(i).getSystemId() == null ? "" : parEntityList.get(i).getSystemId()); property.setSystem(parEntity.getSystemId() == null ? "" : parEntity.getSystemId());
property.setPropertyEntity(parEntityList.get(i).getTableName() == null ? "" : parEntityList.get(i).getTableName()); property.setPropertyEntity(parEntity.getTableName() == null ? "" : parEntity.getTableName());
// 对应存储相同实体id关系 // 对应存储相同实体id关系
for (MetaEntity metaEntity : parEntityList) { propertyMapping.setSelfPropertyColumn(parList.get(i).getCodeName() == null ? "" : parList.get(i).getCodeName());
if (metaEntity.getEntityId().equals(parList.get(i).getRefEntityId())) { propertyMapping.setJoinPropertyName(parList.get(i).getEntityName() == null ? "" : parList.get(i).getEntityName());
propertyMapping.setSelfPropertyColumn(parList.get(i).getCodeName() == null ? "" : parList.get(i).getCodeName()); propertyMapping.setJoinPropertyColumn(parList.get(i).getCodeName() == null ? "" : parList.get(i).getCodeName());
propertyMapping.setJoinPropertyName(parList.get(i).getEntityName() == null ? "" : parList.get(i).getEntityName());
propertyMapping.setJoinPropertyColumn(parList.get(i).getCodeName() == null ? "" : parList.get(i).getCodeName()); // 添加主实体在集合头部
} if (i == 0) {
temp = new Property();
temp.setPropertyName(et.getEntityName());
temp.setSystem(et.getSystemId());
temp.setPropertyEntity(et.getTableName());
parPropertyList.add(temp);
} }
propertyMappingSet = new LinkedHashSet<>(); propertyMappingSet = new LinkedHashSet<>();
parPropertyList.add(property); parPropertyList.add(property);
propertyMappingSet.add(propertyMapping); propertyMappingSet.add(propertyMapping);
property.setPropertyMappings(propertyMappingSet); property.setPropertyMappings(propertyMappingSet);
} }
} }
return parPropertyList; return parPropertyList;
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册