提交 5c2d32b8 编写于 作者: zhouweidong's avatar zhouweidong

数据导入外键值检查

上级 0f778ae6
......@@ -2800,8 +2800,6 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
else{
break;
}
<#--<#comment>外键值校验</#comment>-->
<#--<@checkForeignKey/>-->
}
<#if de.getMinorPSDERs?? && de.getMinorPSDERs()??>
<#list de.getMinorPSDERs() as MinorPSDER>
......@@ -2829,6 +2827,31 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
}
}
}
<#if sys.codeName='Sample'>
<#comment>通过外键值文本填充外键值</#comment>
<#assign foreignkeyId = MajorKeyFieldCodeName>
<#assign foreignkeyField = MajorEntity.getMajorPSDEField()>
<#assign foreignkeyName = srfcaseformat(foreignkeyField.getCodeName(),'l_u2lC')?cap_first>
<#assign importTag=foreignkeyField.getCodeName()>
<#if ((foreignkeyField.getImportTag())!'')!=''>
<#assign importTag=foreignkeyField.getImportTag()>
<#elseif ((foreignkeyField.getLogicName())!'')!=''>
<#assign importTag=foreignkeyField.getLogicName()>
</#if>
if(ObjectUtils.isEmpty(entity.get${foreignkeyId}()) && !ObjectUtils.isEmpty(entity.get${foreignkeyName}())){
QueryWrapper<${MajorEntity.getCodeName()}> ${MinorPSDER.codeName?lower_case}Wrapper = new QueryWrapper<>();
${MinorPSDER.codeName?lower_case}Wrapper.eq("${foreignkeyField.name?lower_case}",entity.get${foreignkeyName}());
${MajorEntity.getCodeName()} ${minder.codeName?lower_case}Entity = ${MajorEntityService}.getOne(${MinorPSDER.codeName?lower_case}Wrapper,false);
if(${MinorPSDER.codeName?lower_case}Entity == null){
Integer lineNum = i + 1;
errorLines.add(lineNum);
errorMsgs.add("第" + lineNum + "行:未能找到[${importTag} : "+entity.get${foreignkeyName}()+"]对应的外键值。");
continue;
}else{
entity.set${foreignkeyId}(${MinorPSDER.codeName?lower_case}Entity.get${foreignkeyId}());
}
}
</#if>
</#if>
</#if>
</#list>
......@@ -3167,8 +3190,8 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
</#if>
</#macro>
<#comment>外键值文本转成外键</#comment>
<#macro checkForeignKey>
<#comment>通过外键值文本填充外键值</#comment>
<#macro fillForeignKeyByText>
<#if sys.codeName='Sample'>
//填充外键值
<#list item.getMinorPSDERs() as minder>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册