提交 e100cf9b 编写于 作者: sq3536's avatar sq3536

联合主键

上级 e2795968
......@@ -233,7 +233,9 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable {
@Override
public Serializable getDefaultKey(boolean gen) {
return DigestUtils.md5DigestAsHex(${getUnionKey(item.getUnionKeyValuePSDEFields())}.getBytes());
${checkUnionKey(item.getUnionKeyValuePSDEFields())}
return DigestUtils.md5DigestAsHex(${getUnionKey(item.getUnionKeyValuePSDEFields())}.getBytes());
return null;
}
</#if>
}
......@@ -386,6 +388,29 @@ public class ${item.getCodeName()} extends EntityMongo implements Serializable {
</#if>
</#if>
<#comment>联合主键</#comment>
<#if item.getUnionKeyValuePSDEFields()??>
<#assign keyField = item.getKeyPSDEField()>
<#assign privateCodeName = srfcaseformat(keyField.getCodeName(),'l_u2lC') >
<#assign publicCodeName = privateCodeName?cap_first >
/**
* 获取 [${keyField.getLogicName()}]
*/
public ${srfjavatype(keyField.getStdDataType())} get${publicCodeName}(){
if(ObjectUtils.isEmpty(${privateCodeName})){
${privateCodeName}=(${srfjavatype(keyField.stdDataType)})getDefaultKey(true);
}
return ${privateCodeName};
}
@Override
public Serializable getDefaultKey(boolean gen) {
${checkUnionKey(item.getUnionKeyValuePSDEFields())}
return DigestUtils.md5DigestAsHex(${getUnionKey(item.getUnionKeyValuePSDEFields())}.getBytes());
return null;
}
</#if>
}
<#comment>Api存储</#comment>
......@@ -558,6 +583,20 @@ public class ${item.getCodeName()} extends EntityClient implements Serializable
<#return unionKeyResult>
</#function>
<#function checkUnionKey unionKeyList>
<#assign formatValue="">
<#list item.getUnionKeyValuePSDEFields() as defield>
<#assign unionKeyPrivateCodeName = srfcaseformat(defield.getCodeName(),'l_u2lC') >
<#assign unionKeyPublicCodeName = unionKeyPrivateCodeName?cap_first >
<#assign formatValue=formatValue+"(!ObjectUtils.isEmpty(this.get"+unionKeyPublicCodeName+"()))">
<#if defield_has_next>
<#assign formatValue=formatValue+"&&">
</#if>
</#list>
<#assign unionKeyResult="if("+formatValue+")">
<#return unionKeyResult>
</#function>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册