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

fillParent

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