提交 9af348d0 编写于 作者: zhouweidong's avatar zhouweidong

虚拟联合主键

上级 dc7d4e8e
......@@ -308,7 +308,7 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable {
if(!ObjectUtils.isEmpty(${prvateCodeName})){
String [] args=${prvateCodeName}.split("\\|\\|");
if(args.length==${unionKeySize}){
${checkUnionKey(item.getUnionKeyValuePSDEFields())}{
${checkUnionKey2(item.getUnionKeyValuePSDEFields())}{
<#list item.getUnionKeyValuePSDEFields() as defield>
<#assign unionKeyPrivateCodeName = srfcaseformat(defield.getCodeName(),'l_u2lC') >
<#assign unionKeyPublicCodeName = unionKeyPrivateCodeName?cap_first >
......@@ -913,6 +913,19 @@ public class ${item.getCodeName()} extends EntityBase implements Serializable {
<#return unionKeyResult>
</#function>
<#comment>虚拟主键拆到联合键值:拆分前空值判断</#comment>
<#function checkUnionKey2 unionKeyList>
<#assign formatValue="">
<#list item.getUnionKeyValuePSDEFields() as defield>
<#assign formatValue=formatValue+"(!ObjectUtils.isEmpty(args["+defield_index+"]))">
<#if defield_has_next>
<#assign formatValue=formatValue+"&&">
</#if>
</#list>
<#assign unionKeyResult="if("+formatValue+")">
<#return unionKeyResult>
</#function>
......
......@@ -924,7 +924,7 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa
public boolean updateById(${item.getCodeName()} et){
UpdateWrapper<${item.getCodeName()}> wrapper=et.getUpdateWrapper(true);
if(ObjectUtils.isEmpty(entity.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}())){
if(ObjectUtils.isEmpty(et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}())){
log.error("更新数据失败,联合键值为空");
return false;
}
......@@ -934,7 +934,7 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa
private boolean updateBatchById(List<${item.getCodeName()}> ets, int batchSize){
for(${item.getCodeName()} et: ets){
if(!updateById(et))
throw new BadRequestAlertException(String.format("更新[{}]数据失败",entity.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}()),"","");
throw new BadRequestAlertException(String.format("更新[{}]数据失败",et.get${srfcaseformat(keyfield.codeName,'l_u2lC')?cap_first}()),"","");
}
return true;
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册