提交 04469c92 编写于 作者: ibiz4j's avatar ibiz4j

fillParent

上级 42fcee83
...@@ -8,6 +8,8 @@ import lombok.Setter; ...@@ -8,6 +8,8 @@ import lombok.Setter;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import net.ibizsys.model.dataentity.defield.IPSDEField; import net.ibizsys.model.dataentity.defield.IPSDEField;
import net.ibizsys.model.dataentity.der.IPSDERBase; import net.ibizsys.model.dataentity.der.IPSDERBase;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -109,6 +111,10 @@ public class RelationshipModel extends BaseModel{ ...@@ -109,6 +111,10 @@ public class RelationshipModel extends BaseModel{
return fkField; return fkField;
} }
public int getRelFieldCount()
{
return ObjectUtils.isEmpty(fields)?1:fields.size();
}
private Map<String,LookupModel> lookup; private Map<String,LookupModel> lookup;
......
...@@ -31,6 +31,9 @@ import org.springframework.data.annotation.Transient; ...@@ -31,6 +31,9 @@ import org.springframework.data.annotation.Transient;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
{{#entity.relEntities}}
import {{packageName}}.core.{{module}}.domain.{{codeName}};
{{/entity.relEntities}}
@Getter @Getter
@Setter @Setter
...@@ -70,7 +73,7 @@ public class {{entity.codeName}} extends EntityMP implements Serializable ...@@ -70,7 +73,7 @@ public class {{entity.codeName}} extends EntityMP implements Serializable
*/ */
@JSONField(name = "{{lowerCase codeName}}") @JSONField(name = "{{lowerCase codeName}}")
@JsonProperty("{{lowerCase codeName}}") @JsonProperty("{{lowerCase codeName}}")
private {{packageName}}.core.{{module}}.domain.{{entityCodeName}} {{camelCase codeName}}; private {{entityCodeName}} {{camelCase codeName}};
{{/each}} {{/each}}
{{#each entity.nesteds}} {{#each entity.nesteds}}
...@@ -84,7 +87,7 @@ public class {{entity.codeName}} extends EntityMP implements Serializable ...@@ -84,7 +87,7 @@ public class {{entity.codeName}} extends EntityMP implements Serializable
@JsonIgnore @JsonIgnore
@JSONField(serialize = false) @JSONField(serialize = false)
{{/if}} {{/if}}
private List<{{packageName}}.core.{{module}}.domain.{{entityCodeName}}> {{camelCase codeName}}; private List<{{entityCodeName}}> {{camelCase codeName}};
{{/each}} {{/each}}
{{#each entity.fields}} {{#each entity.fields}}
......
...@@ -34,6 +34,9 @@ import io.swagger.annotations.ApiModelProperty; ...@@ -34,6 +34,9 @@ import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.baomidou.mybatisplus.annotation.*; import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.IdWorker;
{{#entity.relEntities}}
import {{packageName}}.core.{{module}}.domain.{{codeName}};
{{/entity.relEntities}}
@Getter @Getter
@Setter @Setter
...@@ -87,7 +90,7 @@ public class {{entity.codeName}} extends EntityMP implements Serializable ...@@ -87,7 +90,7 @@ public class {{entity.codeName}} extends EntityMP implements Serializable
@JsonIgnore @JsonIgnore
@JSONField(serialize = false) @JSONField(serialize = false)
@TableField(exist = false) @TableField(exist = false)
private {{packageName}}.core.{{module}}.domain.{{entityCodeName}} {{camelCase codeName}}; private {{entityCodeName}} {{camelCase codeName}};
{{/each}} {{/each}}
{{#each entity.nesteds}} {{#each entity.nesteds}}
...@@ -106,7 +109,7 @@ public class {{entity.codeName}} extends EntityMP implements Serializable ...@@ -106,7 +109,7 @@ public class {{entity.codeName}} extends EntityMP implements Serializable
{{else}} {{else}}
@TableField(exist = false) @TableField(exist = false)
{{/if}} {{/if}}
protected List<{{packageName}}.core.{{module}}.domain.{{entityCodeName}}> {{camelCase codeName}}; protected List<{{entityCodeName}}> {{camelCase codeName}};
{{/each}} {{/each}}
{{#each entity.fields}} {{#each entity.fields}}
...@@ -144,7 +147,7 @@ public class {{entity.codeName}} extends EntityMP implements Serializable ...@@ -144,7 +147,7 @@ public class {{entity.codeName}} extends EntityMP implements Serializable
/** /**
* 设置 [{{entityLogicName}}] * 设置 [{{entityLogicName}}]
*/ */
public {{entity.codeName}} set{{pascalCase codeName}}(List<{{packageName}}.core.{{module}}.domain.{{entityCodeName}}> {{camelCase codeName}}) { public {{entity.codeName}} set{{pascalCase codeName}}(List<{{entityCodeName}}> {{camelCase codeName}}) {
this.{{camelCase codeName}} = {{camelCase codeName}}; this.{{camelCase codeName}} = {{camelCase codeName}};
this.modify("{{columnName}}", ({{camelCase codeName}}!=null)?{{camelCase codeName}}:(new ArrayList())); this.modify("{{columnName}}", ({{camelCase codeName}}!=null)?{{camelCase codeName}}:(new ArrayList()));
return this; return this;
......
...@@ -33,6 +33,9 @@ import org.springframework.data.annotation.Transient; ...@@ -33,6 +33,9 @@ import org.springframework.data.annotation.Transient;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
{{#entity.relEntities}}
import {{packageName}}.core.{{module}}.domain.{{codeName}};
{{/entity.relEntities}}
@Getter @Getter
@Setter @Setter
...@@ -72,7 +75,7 @@ public class {{entity.codeName}} extends EntityClient implements Serializable ...@@ -72,7 +75,7 @@ public class {{entity.codeName}} extends EntityClient implements Serializable
*/ */
@JSONField(name = "{{lowerCase codeName}}") @JSONField(name = "{{lowerCase codeName}}")
@JsonProperty("{{lowerCase codeName}}") @JsonProperty("{{lowerCase codeName}}")
private {{packageName}}.core.{{module}}.domain.{{entityCodeName}} {{camelCase codeName}}; private {{entityCodeName}} {{camelCase codeName}};
{{/each}} {{/each}}
{{#each entity.nesteds}} {{#each entity.nesteds}}
...@@ -86,7 +89,7 @@ public class {{entity.codeName}} extends EntityClient implements Serializable ...@@ -86,7 +89,7 @@ public class {{entity.codeName}} extends EntityClient implements Serializable
@JsonIgnore @JsonIgnore
@JSONField(serialize = false) @JSONField(serialize = false)
{{/if}} {{/if}}
private List<{{packageName}}.core.{{module}}.domain.{{entityCodeName}}> {{camelCase codeName}}; private List<{{entityCodeName}}> {{camelCase codeName}};
{{/each}} {{/each}}
{{#each entity.fields}} {{#each entity.fields}}
......
...@@ -92,7 +92,13 @@ public interface I{{entity.codeName}}Service extends IService<{{entity.codeName} ...@@ -92,7 +92,13 @@ public interface I{{entity.codeName}}Service extends IService<{{entity.codeName}
{{#enableEntityCache}} {{#enableEntityCache}}
@CacheEvict(value = "{{lowerCase entity.codeName}}", allEntries = true) @CacheEvict(value = "{{lowerCase entity.codeName}}", allEntries = true)
{{/enableEntityCache}} {{/enableEntityCache}}
boolean saveBy{{pascalCase fkField.codeName}}({{fkField.type.java}} {{camelCase fkField.codeName}},List<{{entity.codeName}}> list); boolean saveBy{{pascalCase fkField.codeName}}({{packageName}}.core.{{module}}.domain.{{entityCodeName}} {{camelCase entityCodeName}},List<{{entity.codeName}}> list);
{{#enableEntityCache}}
@CacheEvict(value = "{{lowerCase entity.codeName}}", allEntries = true)
{{/enableEntityCache}}
default boolean saveBy{{pascalCase fkField.codeName}}({{fkField.type.java}} {{camelCase fkField.codeName}},List<{{entity.codeName}}> list) {
return saveBy{{pascalCase fkField.codeName}}(new {{packageName}}.core.{{module}}.domain.{{entityCodeName}}().set{{pascalCase relEntity.keyField.codeName}}({{camelCase fkField.codeName}}),list);
}
{{/entity.references}} {{/entity.references}}
} }
\ No newline at end of file
...@@ -43,6 +43,12 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; ...@@ -43,6 +43,12 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.Wrapper;
{{#entity.relEntities}}
import {{packageName}}.core.{{module}}.domain.{{codeName}};
{{#neq storage "NONE"}}
import {{packageName}}.core.{{module}}.service.I{{codeName}}Service;
{{/neq}}
{{/entity.relEntities}}
/** /**
...@@ -60,7 +66,7 @@ public class {{entity.codeName}}ServiceImpl extends ServiceImpl<{{entity.codeNam ...@@ -60,7 +66,7 @@ public class {{entity.codeName}}ServiceImpl extends ServiceImpl<{{entity.codeNam
{{#neq storage "NONE"}} {{#neq storage "NONE"}}
@Autowired @Autowired
@Lazy @Lazy
protected {{packageName}}.core.{{module}}.service.I{{codeName}}Service {{camelCase codeName}}Service; protected I{{codeName}}Service {{camelCase codeName}}Service;
{{/neq}} {{/neq}}
{{/entity.relEntities}} {{/entity.relEntities}}
...@@ -93,7 +99,20 @@ public class {{entity.codeName}}ServiceImpl extends ServiceImpl<{{entity.codeNam ...@@ -93,7 +99,20 @@ public class {{entity.codeName}}ServiceImpl extends ServiceImpl<{{entity.codeNam
{{#entity.hasReferences}} {{#entity.hasReferences}}
public void fillParentData({{entity.codeName}} et) { public void fillParentData({{entity.codeName}} et) {
{{#each entity.references as |reference|}}
{{#gt reference.relFieldCount 1}}
if(!ObjectUtils.isEmpty(et.get{{pascalCase reference.fkField.codeName}}())) {
{{reference.entityCodeName}} {{camelCase reference.entityCodeName}} = et.get{{pascalCase reference.codeName}}();
if(!ObjectUtils.isEmpty({{camelCase reference.entityCodeName}})) {
{{#each reference.fields as |field|}}
{{#neq field.dataType 'PICKUP'}}
et.set{{pascalCase field.codeName}}({{camelCase reference.entityCodeName}}.get{{pascalCase field.refFieldCodeName}}());
{{/neq}}
{{/each}}
}
}
{{/gt}}
{{/each}}
} }
{{/entity.hasReferences}} {{/entity.hasReferences}}
...@@ -117,7 +136,7 @@ public class {{entity.codeName}}ServiceImpl extends ServiceImpl<{{entity.codeNam ...@@ -117,7 +136,7 @@ public class {{entity.codeName}}ServiceImpl extends ServiceImpl<{{entity.codeNam
{{#entity.isIndexSubDE}} {{#entity.isIndexSubDE}}
if(ObjectUtils.isEmpty(et.get{{pascalCase entity.keyField.codeName}}())) if(ObjectUtils.isEmpty(et.get{{pascalCase entity.keyField.codeName}}()))
et.set{{pascalCase entity.keyField.codeName}}(({{entity.keyField.type.java}})et.getDefaultKey(true)); et.set{{pascalCase entity.keyField.codeName}}(({{entity.keyField.type.java}})et.getDefaultKey(true));
{{packageName}}.core.{{entity.indexRelation.module}}.domain.{{entity.indexRelation.entityCodeName}} {{camelCase entity.indexRelation.entityCodeName}} = {{camelCase entity.codeName}}InheritMapping.to{{pascalCase entity.indexRelation.entityCodeName}}(et); {{entity.indexRelation.entityCodeName}} {{camelCase entity.indexRelation.entityCodeName}} = {{camelCase entity.codeName}}InheritMapping.to{{pascalCase entity.indexRelation.entityCodeName}}(et);
{{#if entity.indexRelation.indexTypePSDEField}} {{#if entity.indexRelation.indexTypePSDEField}}
{{camelCase entity.indexRelation.entityCodeName}}.set("{{lowerCase entity.indexRelation.indexTypePSDEField.codeName}}","{{entity.indexRelation.typeValue}}"); {{camelCase entity.indexRelation.entityCodeName}}.set("{{lowerCase entity.indexRelation.indexTypePSDEField.codeName}}","{{entity.indexRelation.typeValue}}");
{{/if}} {{/if}}
...@@ -134,7 +153,7 @@ public class {{entity.codeName}}ServiceImpl extends ServiceImpl<{{entity.codeNam ...@@ -134,7 +153,7 @@ public class {{entity.codeName}}ServiceImpl extends ServiceImpl<{{entity.codeNam
{{#each entity.nesteds}} {{#each entity.nesteds}}
{{#unless listCode}} {{#unless listCode}}
{{#unless columnName}} {{#unless columnName}}
{{camelCase entityCodeName}}Service.saveBy{{pascalCase fkField.codeName}}(et.get{{pascalCase entity.keyField.codeName}}(),et.get{{pascalCase codeName}}()); {{camelCase entityCodeName}}Service.saveBy{{pascalCase fkField.codeName}}(et,et.get{{pascalCase codeName}}());
{{/unless}} {{/unless}}
{{/unless}} {{/unless}}
{{/each}} {{/each}}
...@@ -176,7 +195,7 @@ public class {{entity.codeName}}ServiceImpl extends ServiceImpl<{{entity.codeNam ...@@ -176,7 +195,7 @@ public class {{entity.codeName}}ServiceImpl extends ServiceImpl<{{entity.codeNam
fillParentData(et); fillParentData(et);
{{/entity.hasReferences}} {{/entity.hasReferences}}
{{#entity.isIndexSubDE}} {{#entity.isIndexSubDE}}
{{packageName}}.core.{{entity.indexRelation.module}}.domain.{{entity.indexRelation.entityCodeName}} {{camelCase entity.indexRelation.entityCodeName}} = {{camelCase entity.codeName}}InheritMapping.to{{pascalCase entity.indexRelation.entityCodeName}}(et); {{entity.indexRelation.entityCodeName}} {{camelCase entity.indexRelation.entityCodeName}} = {{camelCase entity.codeName}}InheritMapping.to{{pascalCase entity.indexRelation.entityCodeName}}(et);
{{#if entity.indexRelation.indexTypePSDEField}} {{#if entity.indexRelation.indexTypePSDEField}}
{{camelCase entity.indexRelation.entityCodeName}}.set("{{lowerCase entity.indexRelation.indexTypePSDEField.codeName}}","{{entity.indexRelation.typeValue}}"); {{camelCase entity.indexRelation.entityCodeName}}.set("{{lowerCase entity.indexRelation.indexTypePSDEField.codeName}}","{{entity.indexRelation.typeValue}}");
{{/if}} {{/if}}
...@@ -193,7 +212,7 @@ public class {{entity.codeName}}ServiceImpl extends ServiceImpl<{{entity.codeNam ...@@ -193,7 +212,7 @@ public class {{entity.codeName}}ServiceImpl extends ServiceImpl<{{entity.codeNam
{{#each entity.nesteds}} {{#each entity.nesteds}}
{{#unless listCode}} {{#unless listCode}}
{{#unless columnName}} {{#unless columnName}}
{{camelCase entityCodeName}}Service.saveBy{{pascalCase fkField.codeName}}(et.get{{pascalCase entity.keyField.codeName}}(),et.get{{pascalCase codeName}}()); {{camelCase entityCodeName}}Service.saveBy{{pascalCase fkField.codeName}}(et,et.get{{pascalCase codeName}}());
{{/unless}} {{/unless}}
{{/unless}} {{/unless}}
{{/each}} {{/each}}
...@@ -342,17 +361,18 @@ public class {{entity.codeName}}ServiceImpl extends ServiceImpl<{{entity.codeNam ...@@ -342,17 +361,18 @@ public class {{entity.codeName}}ServiceImpl extends ServiceImpl<{{entity.codeNam
return this.update(new UpdateWrapper<{{entity.codeName}}>().set("{{lowerCase fkField.name}}",null).eq("{{lowerCase fkField.name}}",{{camelCase fkField.codeName}})); return this.update(new UpdateWrapper<{{entity.codeName}}>().set("{{lowerCase fkField.name}}",null).eq("{{lowerCase fkField.name}}",{{camelCase fkField.codeName}}));
} }
public boolean saveBy{{pascalCase fkField.codeName}}({{fkField.type.java}} {{camelCase fkField.codeName}},List<{{entity.codeName}}> list) { public boolean saveBy{{pascalCase fkField.codeName}}({{entityCodeName}} {{camelCase entityCodeName}},List<{{entity.codeName}}> list) {
if(list==null) if(list==null)
return true; return true;
Set<{{entity.keyField.type.java}}> delIds=new HashSet<{{entity.keyField.type.java}}>(); Set<{{entity.keyField.type.java}}> delIds=new HashSet<{{entity.keyField.type.java}}>();
List<{{entity.codeName}}> _update=new ArrayList<{{entity.codeName}}>(); List<{{entity.codeName}}> _update=new ArrayList<{{entity.codeName}}>();
List<{{entity.codeName}}> _create=new ArrayList<{{entity.codeName}}>(); List<{{entity.codeName}}> _create=new ArrayList<{{entity.codeName}}>();
for({{entity.codeName}} before:selectBy{{pascalCase fkField.codeName}}({{camelCase fkField.codeName}})){ for({{entity.codeName}} before:selectBy{{pascalCase fkField.codeName}}({{camelCase entityCodeName}}.get{{pascalCase relEntity.keyField.codeName}}())){
delIds.add(before.get{{pascalCase entity.keyField.codeName}}()); delIds.add(before.get{{pascalCase entity.keyField.codeName}}());
} }
for({{entity.codeName}} sub:list) { for({{entity.codeName}} sub:list) {
sub.set{{pascalCase fkField.codeName}}({{camelCase fkField.codeName}}); sub.set{{pascalCase fkField.codeName}}({{camelCase entityCodeName}}.get{{pascalCase relEntity.keyField.codeName}}());
sub.set{{pascalCase codeName}}({{camelCase entityCodeName}});
if(ObjectUtils.isEmpty(sub.get{{pascalCase entity.keyField.codeName}}())) if(ObjectUtils.isEmpty(sub.get{{pascalCase entity.keyField.codeName}}()))
sub.set{{pascalCase entity.keyField.codeName}}(({{entity.keyField.type.java}})sub.getDefaultKey(true)); sub.set{{pascalCase entity.keyField.codeName}}(({{entity.keyField.type.java}})sub.getDefaultKey(true));
if(delIds.contains(sub.get{{pascalCase entity.keyField.codeName}}())) { if(delIds.contains(sub.get{{pascalCase entity.keyField.codeName}}())) {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册