提交 2e7a1816 编写于 作者: zhouweidong's avatar zhouweidong

copyTo优化

上级 5e297584
...@@ -365,20 +365,21 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable { ...@@ -365,20 +365,21 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable {
</#if> </#if>
<#if hasResetField> <#if hasResetField>
/** /**
* 复制当前对象数据到目标对象 * 复制当前对象数据到目标对象(粘贴重置)
* @param targetEntity * @param targetEntity 目标数据对象
* @param bIncEmpty 是否包括空值
* @param <T> * @param <T>
* @return * @return
*/ */
@Override @Override
public <T> T copyTo(T targetEntity) { public <T> T copyTo(T targetEntity, boolean bIncEmpty) {
<#list de.getPSDEFields() as defield> <#list de.getPSDEFields() as defield>
<#if defield.isPasteReset()==true> <#if defield.isPasteReset()==true>
<#assign columnname = defield.getName()?lower_case> <#assign columnname = defield.getName()?lower_case>
this.reset("${columnname}"); this.reset("${columnname}");
</#if> </#if>
</#list> </#list>
return super.copyTo(targetEntity); return super.copyTo(targetEntity,bIncEmpty);
} }
</#if> </#if>
} }
...@@ -745,20 +746,21 @@ public class ${item.getCodeName()} extends EntityClient implements Serializable ...@@ -745,20 +746,21 @@ public class ${item.getCodeName()} extends EntityClient implements Serializable
</#if> </#if>
<#if hasResetField> <#if hasResetField>
/** /**
* 复制当前对象数据到目标对象 * 复制当前对象数据到目标对象(粘贴重置)
* @param targetEntity * @param targetEntity 目标数据对象
* @param bIncEmpty 是否包括空值
* @param <T> * @param <T>
* @return * @return
*/ */
@Override @Override
public <T> T copyTo(T targetEntity) { public <T> T copyTo(T targetEntity, boolean bIncEmpty) {
<#list de.getPSDEFields() as defield> <#list de.getPSDEFields() as defield>
<#if defield.isPasteReset()==true> <#if defield.isPasteReset()==true>
<#assign columnname = defield.getName()?lower_case> <#assign columnname = defield.getName()?lower_case>
this.reset("${columnname}"); this.reset("${columnname}");
</#if> </#if>
</#list> </#list>
return super.copyTo(targetEntity); return super.copyTo(targetEntity,bIncEmpty);
} }
</#if> </#if>
</#if> </#if>
......
...@@ -103,24 +103,21 @@ public class EntityBase implements Serializable { ...@@ -103,24 +103,21 @@ public class EntityBase implements Serializable {
/** /**
* 复制当前对象数据到目标对象 * 复制当前对象数据到目标对象
* @param targetEntity * @param targetEntity 目标数据对象
* @param bIncEmpty 是否包括空值
* @param <T> * @param <T>
* @return * @return
*/ */
public <T> T copyTo(T targetEntity){ public <T> T copyTo(T targetEntity, boolean bIncEmpty){
if(targetEntity instanceof EntityBase){ if(targetEntity instanceof EntityBase){
EntityBase target= (EntityBase) targetEntity; EntityBase target= (EntityBase) targetEntity;
Hashtable<String, Field> sourceFields=DEFieldCacheMap.getFieldMap(this.getClass()); Hashtable<String, Field> sourceFields=DEFieldCacheMap.getFieldMap(this.getClass());
for(String field : sourceFields.keySet()){ for(String field : sourceFields.keySet()){
Object value=this.get(field); Object value=this.get(field);
if(ObjectUtils.isEmpty(value)) if( !ObjectUtils.isEmpty(value) || ObjectUtils.isEmpty(value) && getFocusNull().contains(field) && bIncEmpty ){
continue;
target.set(field,value); target.set(field,value);
} }
if(!ObjectUtils.isEmpty(this.getFocusNull())) }
target.getFocusNull().addAll(this.getFocusNull());
if(!ObjectUtils.isEmpty(this.getExtensionparams()))
target.getExtensionparams().putAll(this.getExtensionparams());
} }
return targetEntity; return targetEntity;
} }
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册