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

补充do数据拷贝(copyTo)

上级 d9920dfc
<#ibiztemplate>
TARGET=PSDATAENTITY
</#ibiztemplate>
<#assign hasResetField=false>
package ${pub.getPKGCodeName()}.core.${item.getPSSystemModule().getCodeName()?lower_case}.domain;
import java.sql.Timestamp;
......@@ -352,6 +353,30 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable {
return IdWorker.getId();
}
</#if>
<#comment>判断是否有拷贝重置属性</#comment>
<#if de.getPSDEFields()??>
<#comment>输出实体属性</#comment>
<#list de.getPSDEFields() as defield>
<#if defield.isPasteReset()==true>
<#assign hasResetField=true>
<#break>
</#if>
</#list>
</#if>
<#if hasResetField>
@Override
public <T> T copyTo(T targetEntity) {
<#list de.getPSDEFields() as defield>
<#if defield.isPasteReset()==true>
<#assign columnname = defield.getName()?lower_case>
this.reset("${columnname}");
</#if>
</#list>
return super.copyTo(targetEntity);
}
</#if>
}
<#comment>NoSQL存储-MongoDB</#comment>
......
......@@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import org.springframework.cglib.beans.BeanMap;
import org.springframework.data.annotation.Transient;
import org.springframework.util.AlternativeJdkIdGenerator;
import org.springframework.util.ObjectUtils;
import java.io.Serializable;
import java.lang.reflect.Field;
import org.springframework.util.StringUtils;
import java.util.*;
......@@ -99,4 +101,35 @@ public class EntityBase implements Serializable {
this.extensionparams.put(field.toLowerCase(),value);
}
/**
* 复制当前对象数据到目标对象
* @param targetEntity
* @param <T>
* @return
*/
public <T> T copyTo(T targetEntity){
if(targetEntity instanceof EntityBase){
EntityBase target= (EntityBase) targetEntity;
Hashtable<String, Field> sourceFields=DEFieldCacheMap.getFieldMap(this.getClass());
for(String field : sourceFields.keySet()){
Object value=this.get(field);
if(ObjectUtils.isEmpty(value))
continue;
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;
}
/**
* 重置当前数据对象属性值
* @param field
*/
public void reset(String field){
}
}
\ No newline at end of file
......@@ -3,6 +3,8 @@ TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.domain;
import org.springframework.util.StringUtils;
public class EntityClient extends EntityBase {
@Override
......@@ -18,5 +20,14 @@ public class EntityClient extends EntityBase {
}
}
@Override
public void reset(String field) {
if(!StringUtils.isEmpty(field)){
String resetField=field.toLowerCase();
this.set(resetField,null);
this.getFocusNull().remove(resetField);
getExtensionparams().remove(resetField+"dirtyflag");
}
}
}
......@@ -4,6 +4,7 @@ TARGET=PSSYSTEM
package ${pub.getPKGCodeName()}.util.domain;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import org.springframework.util.StringUtils;
public class EntityMP extends EntityBase {
......@@ -27,5 +28,14 @@ public class EntityMP extends EntityBase {
this.getFocusNull().remove(field.toLowerCase());
}
@Override
public void reset(String field){
if(!StringUtils.isEmpty(field)){
String resetField=field.toLowerCase();
this.set(resetField,null);
getFocusNull().remove(resetField);
}
}
}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册