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

实体数据导入

上级 ea5cc5e9
<#ibiztemplate>
TARGET=PSDEDATAIMP
</#ibiztemplate>
package ${pub.getPKGCodeName()}.core.${de.getPSSystemModule().codeName?lower_case}.mapping;
import ${pub.getPKGCodeName()}.core.${de.getPSSystemModule().codeName?lower_case}.domain.${de.codeName};
import org.mapstruct.*;
import java.util.List;
@Mapper(componentModel = "spring", uses = {})
public interface ${de.codeName}${item.codeName} {
<#if item.getPSDEDataImportItems?? && item.getPSDEDataImportItems()??>
@Mappings({
<#list de.getPSDEDataImportItems as importItem>
<#if importItem.getPSDEField()??>
<#assign deFieldName = srfcaseformat(importItem.getPSDEField().getCodeName(),'l_u2lC') >
@Mapping(target = "${deFieldName}",source = "${deFieldName}"),
</#if>
</#list>
})
@BeanMapping(ignoreByDefault = true)
</#if>
${de.codeName} toDomain(${de.codeName} entity);
List<${de.codeName}> toDomain(List<${de.codeName}> entities);
}
...@@ -7,6 +7,14 @@ TARGET=PSDATAENTITY ...@@ -7,6 +7,14 @@ TARGET=PSDATAENTITY
<#if de.getPSDEFieldByPDT('ORGID',true)?? || de.getPSDEFieldByPDT('ORGSECTORID',true)?? || de.getPSDEFieldByPDT('CREATEMAN',true)?? > <#if de.getPSDEFieldByPDT('ORGID',true)?? || de.getPSDEFieldByPDT('ORGSECTORID',true)?? || de.getPSDEFieldByPDT('CREATEMAN',true)?? >
<#assign hasDEPrefield=true> <#assign hasDEPrefield=true>
</#if> </#if>
<#assign hasDEImport=false>
<#comment>实体数据导入</#comment>
<#if de.getAllPSDEDataImports?? && de.getAllPSDEDataImports()??>
<#list de.getAllPSDEDataImports() as deImport>
<#assign hasDEImport=true>
<#break>
</#list>
</#if>
<#if de.getStorageMode()==1 || de.getStorageMode()==2 ||de.getStorageMode()==4||de.getStorageMode()==0> <#if de.getStorageMode()==1 || de.getStorageMode()==2 ||de.getStorageMode()==4||de.getStorageMode()==0>
package ${pub.getPKGCodeName()}.core.${item.getPSSystemModule().getCodeName()?lower_case}.service; package ${pub.getPKGCodeName()}.core.${item.getPSSystemModule().getCodeName()?lower_case}.service;
...@@ -194,6 +202,10 @@ public interface I${item.codeName}Service{ ...@@ -194,6 +202,10 @@ public interface I${item.codeName}Service{
</#if> </#if>
</#list> </#list>
</#if> </#if>
<#comment>实体数据导入</#comment>
<#if hasDEImport>
JSONObject importData(List<${de.codeName}> entities,int batchSize,boolean isIgnoreError);
</#if>
</#macro> </#macro>
<#comment>输出测试行为</#comment> <#comment>输出测试行为</#comment>
......
...@@ -22,6 +22,14 @@ TARGET=PSDESERVICEAPI ...@@ -22,6 +22,14 @@ TARGET=PSDESERVICEAPI
<#if de.getPSDEFieldByPDT('ORGID',true)?? || de.getPSDEFieldByPDT('ORGSECTORID',true)?? || de.getPSDEFieldByPDT('CREATEMAN',true)?? > <#if de.getPSDEFieldByPDT('ORGID',true)?? || de.getPSDEFieldByPDT('ORGSECTORID',true)?? || de.getPSDEFieldByPDT('CREATEMAN',true)?? >
<#assign hasDEPrefield=true> <#assign hasDEPrefield=true>
</#if> </#if>
<#assign hasDEImport=false>
<#comment>实体数据导入</#comment>
<#if de.getAllPSDEDataImports?? && de.getAllPSDEDataImports()??>
<#list de.getAllPSDEDataImports() as deImport>
<#assign hasDEImport=true>
<#break>
</#list>
</#if>
package ${pubPkgCodeName}.${itemSysApiCodeNameLC}.rest; package ${pubPkgCodeName}.${itemSysApiCodeNameLC}.rest;
import java.sql.Timestamp; import java.sql.Timestamp;
...@@ -614,7 +622,37 @@ public class ${itemCodeName}Resource { ...@@ -614,7 +622,37 @@ public class ${itemCodeName}Resource {
</#if> </#if>
</#list> </#list>
</#if> </#if>
<#-- 关系接口 end --> <#comment>实体数据导入</#comment>
<#if hasDEImport>
<#list de.getAllPSDEDataImports() as deImport>
@Autowired
${pub.getPKGCodeName()}.core.${de.getPSSystemModule().codeName?lower_case}.mapping.${deCodeName}${deImport.codeName} ${deImport.codeName?lower_case}ImpMapping;
</#list>
@RequestMapping(method = RequestMethod.POST, value = "/${srfpluralize(itemCodeNameLC)}/import")
public ResponseEntity<JSONObject> importData(@RequestParam(value = "name") String config , @RequestBody List<${deCodeName}> dtos){
JSONObject rs=new JSONObject();
if(dtos.size()==0){
rs.put("rst", 1);
rs.put("msg", "未传入内容");
return ResponseEntity.status(HttpStatus.NO_CONTENT).body(rs);
}
else{
<#list de.getAllPSDEDataImports() as deImport>
<#if deImport_index==0>
if(config.equals("${deImport.codeName}")){
rs=${deCodeNameLC}Service.importData(${deImport.codeName?lower_case}ImpMapping.toDomain(dtos),${deImport.getBatchSize()},${deImport.isIgnoreError()?c});
}
<#else>
else if(config.equals("${deImport.codeName}")){
rs=${deCodeNameLC}Service.importData(${deImport.codeName?lower_case}ImpMapping.toDomain(dtos),${deImport.getBatchSize()},${deImport.isIgnoreError()?c});
}
</#if>
</#list>
return ResponseEntity.status(HttpStatus.OK).body(rs);
}
}
</#if>
} }
</#if> </#if>
</#if> </#if>
......
...@@ -98,9 +98,9 @@ public class DEFieldDefaultValueAspect ...@@ -98,9 +98,9 @@ public class DEFieldDefaultValueAspect
for(Object item:(List)obj) { for(Object item:(List)obj) {
if(item instanceof EntityBase) { if(item instanceof EntityBase) {
if(deFields==null) { if(deFields==null) {
deFields = DEFieldCacheMap.getDEFields(obj.getClass()); deFields = DEFieldCacheMap.getDEFields(item.getClass());
curUser = AuthenticationUser.getAuthenticationUser(); curUser = AuthenticationUser.getAuthenticationUser();
keyField=DEFieldCacheMap.getDEKeyField(obj.getClass()); keyField=DEFieldCacheMap.getDEKeyField(item.getClass());
if(StringUtils.isEmpty(keyField)) if(StringUtils.isEmpty(keyField))
return true; return true;
} }
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册