提交 5422615e 编写于 作者: zhouweidong's avatar zhouweidong

联合主键

上级 7b99a3e8
......@@ -212,7 +212,47 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable {
</#if>
</#list>
</#if>
<#comment>联合主键</#comment>
<#if item.getUnionKeyValuePSDEFields()??>
<#assign keyField = item.getKeyPSDEField()>
<#assign privateCodeName = srfcaseformat(keyField.getCodeName(),'l_u2lC') >
<#assign publicCodeName = prvateCodeName?cap_first >
/**
* 获取 [${keyField.getLogicName()}]
*/
public void get${publicCodeName}(${srfjavatype(keyField.getStdDataType())} ${privateCodeName}){
if(org.springframework.util.ObjectUtils.isEmpty(${privateCodeName})){
${privateCodeName}=(${srfjavatype(keyfield.stdDataType)})getDefaultKey(true);
}
return ${privateCodeName};
}
@Override
public Serializable getDefaultKey(boolean gen) {
return org.springframework.util.DigestUtils.md5DigestAsHex(${getUnionKey(item.getUnionKeyValuePSDEFields())}).getBytes());
}
</#if>
}
<#comment>获取联合主键:返回值 String.format("%s||%s",this.getHumanid(),this.getHumanname() </#comment>
<#function getUnionKey unionKeyList>
<#assign formatKey="">
<#assign formatValue="">
<#list item.getUnionKeyValuePSDEFields() as defield>
<#assign unionKeyPrivateCodeName = srfcaseformat(defield.getCodeName(),'l_u2lC') >
<#assign unionKeyPublicCodeName = unionKeyPrivateCodeName?cap_first >
<#assign formatKey=formatKey+"%s">
<#if defield_has_next>
<#assign formatKey=formatKey+"||">
</#if>
<#assign formatValue=formatValue+"this.get"+unionKeyPublicCodeName+"()">
<#if defield_has_next>
<#assign formatValue=formatValue+",">
</#if>
</#list>
<#assign unionKeyResult="String.format(\""+formatKey+"\" ,"+formatValue+")">
<#return unionKeyResult>
</#function>
<#comment>NoSQL存储-MongoDB</#comment>
<#elseif de.getStorageMode()==2>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册