提交 46ff0077 编写于 作者: xignzi006's avatar xignzi006

Merge branch 'master' of I:\workspace\Template\ibizlab-generator with conflicts.

上级 8bad5285
......@@ -43,6 +43,17 @@ public class ApiMethodModel extends BaseModel {
return (IPSDEServiceAPIMethod) opt;
}
public String getMethodName() {
String strName = super.getName();
if (CollectionUtils.isNotEmpty(parentApiEntities)) {
strName += "By";
for (ApiEntityRSModel parent : parentApiEntities) {
strName += StringAdvUtils.pascalcase(parent.getParentIdFieldCodeName());
}
}
return strName;
}
public String getRequestPath() {
String path = "";
if (!CollectionUtils.isEmpty(parentApiEntities)) {
......
......@@ -621,7 +621,7 @@ public class EntityModel extends BaseModel {
if(der.getMajorPSDataEntity().getKeyPSDEField()!=null)
{
LookupModel lookupModel = new LookupModel().setRelationid(der.getId())
.setFieldname(this.getDataEntity().getMajorPSDEField().getName()).setCodeName(this.getDataEntity().getMajorPSDEField().getCodeName())
.setFieldname(this.getDataEntity().getKeyPSDEField().getName()).setCodeName(this.getDataEntity().getKeyPSDEField().getCodeName())
.setReffieldname(der.getMajorPSDataEntity().getKeyPSDEField().getName()).setRefCodeName(der.getMajorPSDataEntity().getKeyPSDEField().getCodeName());
rel.addLookup(lookupModel);
}
......@@ -653,7 +653,7 @@ public class EntityModel extends BaseModel {
rel.setRelationType("inherit");
this.setIndexRelation(rel);
}
else if("DERINDEX".equals(der.getDERType())&& der.getMajorPSDataEntity().getVirtualMode()!=3
else if("DERINDEX".equals(der.getDERType())//&& der.getMajorPSDataEntity().getVirtualMode()!=3
&& der.getMajorPSDataEntity().getIndexTypePSDEField()!=null)
{
rel.setRelationType("index");
......
package cn.ibizlab.codegen.model;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import net.ibizsys.model.service.IPSSubSysServiceAPI;
import net.ibizsys.model.service.IPSSubSysServiceAPIDE;
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
public class SubEntityApiModel extends BaseModel {
private SubServiceApiModel subServiceApi;
public SubEntityApiModel(SubServiceApiModel subServiceApiModel, IPSSubSysServiceAPIDE iPSSubSysServiceAPIDE) {
subServiceApi = subServiceApiModel;
this.opt = iPSSubSysServiceAPIDE;
this.setCodeName(iPSSubSysServiceAPIDE.getCodeName());
this.setName(iPSSubSysServiceAPIDE.getName());
}
}
package cn.ibizlab.codegen.model;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import net.ibizsys.model.service.IPSSubSysServiceAPI;
import java.util.*;
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
public class SubServiceApiModel extends BaseModel {
private SystemModel system;
private Map<String, SubEntityApiModel> subEntityApi = new LinkedHashMap<>();
public SubServiceApiModel(IPSSubSysServiceAPI iPSSubSysServiceAPI) {
this.opt = iPSSubSysServiceAPI;
this.setCodeName(iPSSubSysServiceAPI.getCodeName());
this.setName(iPSSubSysServiceAPI.getName());
}
public Collection<SubEntityApiModel> getSubEntityApis() {
return subEntityApi.values();
}
public SubEntityApiModel getSubEntityApi(String codeName) {
return subEntityApi.get(codeName);
}
}
......@@ -107,9 +107,9 @@ public class SystemModel extends BaseModel {
enableMongo=true;
if(ObjectUtils.isEmpty(entity.getAllPSDEWFs()))
enableWorkflow=true;
if("elasticsearch".equalsIgnoreCase(entity.getUserTag()))
if(!enableES && "elasticsearch".equalsIgnoreCase(entity.getUserTag()))
enableES=true;
if(!ObjectUtils.isEmpty(entity.getAllPSDEDataSyncs()))
if(!enableMQ && !ObjectUtils.isEmpty(entity.getAllPSDEDataSyncs()))
enableMQ=true;
if(entity.getAllPSDEDataSyncs()!=null)
{
......@@ -187,6 +187,24 @@ public class SystemModel extends BaseModel {
return getApisMap().values();
}
private Map<String,SubServiceApiModel> subServiceApiMap;
public synchronized Map<String, SubServiceApiModel> getSubServiceApiMap() {
if(subServiceApiMap==null)
{
subServiceApiMap=new LinkedHashMap<>();
getSystem().getAllPSSubSysServiceAPIs().forEach(subSysServiceAPI->{
subServiceApiMap.put(subSysServiceAPI.getCodeName(),new SubServiceApiModel(subSysServiceAPI).setSystem(this));
});
}
return subServiceApiMap;
}
public Collection<SubServiceApiModel> getSubServiceApi()
{
return getSubServiceApiMap().values();
}
public EntityModel getEntity(String codeName)
......
......@@ -9,21 +9,26 @@ public enum TemplateFileType {
apiDto(Constants.API_DTOS),
entity(Constants.ENTITIES),
module(Constants.MODULES),
subService(Constants.SUB_SERVICEAPI),
subEntity(Constants.SUB_ENTITIES),
api(Constants.APIS),
app(Constants.APPS),
supportingFiles(Constants.SUPPORTING_FILES);
private final String templateType;
TemplateFileType(String templateType) { this.templateType = templateType; }
TemplateFileType(String templateType) {
this.templateType = templateType;
}
/**
* Returns the value for this template file type
*
* @return The template type of this enum.
*/
public String value() { return this.templateType; }
public String value() {
return this.templateType;
}
/**
......@@ -45,6 +50,8 @@ public enum TemplateFileType {
public static final String APIS = "apis";
public static final String APPS = "apps";
public static final String ENTITIES = "entities";
public static final String SUB_SERVICEAPI = "subServiceApi";
public static final String SUB_ENTITIES = "subEntities";
public static final String API_ENTITIES = "apiEntities";
public static final String API_DTOS = "apiDtos";
public static final String APP_ENTITIES = "appEntities";
......
{{#system.enableMQ}}
package {{packageName}}.core.util.aspect;
import com.alibaba.fastjson.JSON;
......@@ -129,4 +130,5 @@ public class RocketMQAspect
log.error("消息发送异常," + e);
}
}
}
\ No newline at end of file
}
{{/system.enableMQ}}
\ No newline at end of file
{{#system.enableMQ}}
package {{packageName}}.core.util.config;
import lombok.extern.slf4j.Slf4j;
......@@ -74,4 +75,5 @@ public class RocketMQConsumer {
}
return consumer;
}
}
\ No newline at end of file
}
{{/system.enableMQ}}
\ No newline at end of file
{{#system.enableMQ}}
package {{packageName}}.core.util.config;
import com.alibaba.fastjson.JSON;
......@@ -68,4 +69,5 @@ public class RocketMQListenerProcessor implements MessageListenerOrderly {
}
return ConsumeOrderlyStatus.SUCCESS;
}
}
\ No newline at end of file
}
{{/system.enableMQ}}
\ No newline at end of file
{{#system.enableMQ}}
package {{packageName}}.core.util.config;
import lombok.extern.slf4j.Slf4j;
......@@ -55,3 +56,4 @@ public class RocketMQProducer {
return producer;
}
}
{{/system.enableMQ}}
\ No newline at end of file
package {{packageName}}.core.{{entity.module}}.domain;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.math.BigInteger;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import cn.ibizlab.util.domain.EntityClient;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import org.springframework.util.ObjectUtils;
import org.springframework.util.DigestUtils;
import cn.ibizlab.util.domain.EntityBase;
import cn.ibizlab.util.annotation.DEField;
import cn.ibizlab.util.enums.DEPredefinedFieldType;
import cn.ibizlab.util.enums.DEFieldDefaultValueType;
import cn.ibizlab.util.helper.DataObject;
import cn.ibizlab.util.annotation.Audit;
import cn.ibizlab.util.enums.DupCheck;
import cn.ibizlab.util.domain.EntityMP;
import java.io.Serializable;
import lombok.*;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Transient;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
@JsonIgnoreProperties(value = "handler")
@ApiModel("{{entity.logicName}}")
public class {{entity.codeName}} extends EntityClient implements Serializable
{
{{#each entity.fields}}
{{#unless deepStructure}}
/**
* {{logicName}}
*/
{{#enableAudit}}
@Audit
{{/enableAudit}}
@DEField({{annotation}})
@JsonProperty("{{jsonName}}")
{{#timeType}}
@JsonFormat(pattern = "{{format}}", locale = "zh", timezone = "GMT+8")
{{/timeType}}
@JSONField(name = "{{jsonName}}"{{#timeType}} , format = "{{format}}"{{/timeType}})
{{#eq type.java "Long"}}
@JsonSerialize(using = ToStringSerializer.class)
{{/eq}}
@ApiModelProperty("{{logicName}}")
private {{type.java}} {{camelCase codeName}};
{{/unless}}
{{/each}}
{{#each entity.references}}
/**
* {{entityLogicName}}
*/
@JSONField(name = "{{lowerCase codeName}}")
@JsonProperty("{{lowerCase codeName}}")
private {{packageName}}.core.{{module}}.domain.{{entityCodeName}} {{camelCase codeName}};
{{/each}}
{{#each entity.nesteds}}
/**
* {{entityLogicName}}
*/
{{#if listCode}}
@JSONField(name = "{{listCode}}")
@JsonProperty("{{listCode}}")
{{else}}
@JsonIgnore
@JSONField(serialize = false)
{{/if}}
private List<{{packageName}}.core.{{module}}.domain.{{entityCodeName}}> {{camelCase codeName}};
{{/each}}
{{#each entity.fields}}
{{#unless deepStructure}}
{{#timeType}}
/**
* 格式化日期 [{{logicName}}]
*/
public String format{{pascalCase codeName}}() {
if (this.{{camelCase codeName}} == null) {
return null;
}
SimpleDateFormat sdf = new SimpleDateFormat("{{format}}");
return sdf.format({{camelCase codeName}});
}
{{/timeType}}
{{/unless}}
{{/each}}
}
\ No newline at end of file
......@@ -10,6 +10,8 @@ import java.util.HashMap;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
......
package {{packageName}}.core.{{entity.module}}.filter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;
import lombok.extern.slf4j.Slf4j;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.alibaba.fastjson.annotation.JSONField;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
{{#entity.enableES}}
import org.elasticsearch.index.query.QueryBuilders;
{{/entity.enableES}}
import cn.ibizlab.util.filter.QueryWrapperContext;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import {{packageName}}.core.{{entity.module}}.domain.{{entity.codeName}};
/**
* 关系型数据实体[{{entity.codeName}}] 查询条件对象
*/
@Slf4j
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
@ApiModel("{{entity.logicName}}")
public class {{entity.codeName}}SearchContext extends QueryWrapperContext<{{entity.codeName}}> {
{{#each entity.fields as |field|}}
{{#each field.allPSDEFSearchModes as |formitem|}}
{{#if (or (eq formitem.valueOP "IN") (eq formitem.valueOP "ISNULL") (eq formitem.valueOP "ISNOTNULL"))}}
@JsonProperty("{{lowerCase formitem.name}}")
@JSONField(name = "{{lowerCase formitem.name}}")
{{else}}
@JsonProperty("{{lowerCase formitem.name}}")
{{#timeType}}
@JsonFormat(pattern = "{{format}}", locale = "zh", timezone = "GMT+8")
{{/timeType}}
@JSONField(name = "{{lowerCase formitem.name}}"{{#timeType}} , format = "{{format}}"{{/timeType}})
{{#eq type.java "Long"}}
@JsonSerialize(using = ToStringSerializer.class)
{{/eq}}
{{/if}}
@ApiModelProperty("{{field.logicName}}{{formitem.valueOP}}")
private {{#if (or (eq formitem.valueOP "IN") (eq formitem.valueOP "ISNULL") (eq formitem.valueOP "ISNOTNULL"))}}String{{else}}{{field.type.java}}{{/if}} {{camelCase field.codeName}}{{formitem.valueOP}};
public {{entity.codeName}}SearchContext set{{pascalCase field.codeName}}{{formitem.valueOP}}({{#if (or (eq formitem.valueOP "IN") (eq formitem.valueOP "ISNULL") (eq formitem.valueOP "ISNOTNULL"))}}String{{else}}{{field.type.java}}{{/if}} {{camelCase field.codeName}}{{formitem.valueOP}}) {
this.{{camelCase field.codeName}}{{formitem.valueOP}} = {{camelCase field.codeName}}{{formitem.valueOP}};
if(!ObjectUtils.isEmpty(this.{{camelCase field.codeName}}{{formitem.valueOP}})){
{{#eq formitem.valueOP "LIKE"}}
this.getSearchCond().like("{{lowerCase field.name}}", {{camelCase field.codeName}}{{formitem.valueOP}});
{{/eq}}
{{#eq formitem.valueOP "LEFTLIKE"}}
this.getSearchCond().likeRight("{{lowerCase field.name}}", {{camelCase field.codeName}}{{formitem.valueOP}});
{{/eq}}
{{#eq formitem.valueOP "RIGHTLIKE"}}
this.getSearchCond().likeLeft("{{lowerCase field.name}}", {{camelCase field.codeName}}{{formitem.valueOP}});
{{/eq}}
{{#eq formitem.valueOP "EQ"}}
this.getSearchCond().eq("{{lowerCase field.name}}", {{camelCase field.codeName}}{{formitem.valueOP}});
{{/eq}}
{{#eq formitem.valueOP "NOTEQ"}}
this.getSearchCond().ne("{{lowerCase field.name}}", {{camelCase field.codeName}}{{formitem.valueOP}});
{{/eq}}
{{#eq formitem.valueOP "GT"}}
this.getSearchCond().gt("{{lowerCase field.name}}", {{camelCase field.codeName}}{{formitem.valueOP}});
{{/eq}}
{{#eq formitem.valueOP "GTANDEQ"}}
this.getSearchCond().ge("{{lowerCase field.name}}", {{camelCase field.codeName}}{{formitem.valueOP}});
{{/eq}}
{{#eq formitem.valueOP "LT"}}
this.getSearchCond().lt("{{lowerCase field.name}}", {{camelCase field.codeName}}{{formitem.valueOP}});
{{/eq}}
{{#eq formitem.valueOP "LTANDEQ"}}
this.getSearchCond().le("{{lowerCase field.name}}", {{camelCase field.codeName}}{{formitem.valueOP}});
{{/eq}}
{{#eq formitem.valueOP "ISNOTNULL"}}
if(this.{{camelCase field.codeName}}{{formitem.valueOP}}.equals("1")){
this.getSearchCond().isNotNull("{{lowerCase field.name}}");
}
{{/eq}}
{{#eq formitem.valueOP "ISNULL"}}
if(this.{{camelCase field.codeName}}{{formitem.valueOP}}.equals("1")){
this.getSearchCond().isNull("{{lowerCase field.name}}");
}
{{/eq}}
{{#eq formitem.valueOP "IN"}}
this.getSearchCond().in("{{lowerCase field.name}}",this.{{camelCase field.codeName}}{{formitem.valueOP}}.split(";|,|;|,"));
{{/eq}}
{{#eq formitem.valueOP "NOTIN"}}
this.getSearchCond().notIn("{{lowerCase field.name}}",this.{{camelCase field.codeName}}{{formitem.valueOP}}.split(";|,|;|,"));
{{/eq}}
{{#if entity.enableES}}
{{#eq formitem.valueOP "LIKE"}}
this.getEsCond().must(QueryBuilders.wildcardQuery("{{lowerCase field.name}}", String.format("*%s*",{{camelCase field.codeName}}{{formitem.valueOP}})));
{{/eq}}
{{#eq formitem.valueOP "LEFTLIKE"}}
this.getEsCond().must(QueryBuilders.wildcardQuery("{{lowerCase field.name}}", String.format("%s*",{{camelCase field.codeName}}{{formitem.valueOP}})));
{{/eq}}
{{#eq formitem.valueOP "RIGHTLIKE"}}
this.getEsCond().must(QueryBuilders.wildcardQuery("{{lowerCase field.name}}", String.format("*%s",{{camelCase field.codeName}}{{formitem.valueOP}})));
{{/eq}}
{{#eq formitem.valueOP "EQ"}}
this.getEsCond().must(QueryBuilders.termQuery("{{lowerCase field.name}}", {{camelCase field.codeName}}{{formitem.valueOP}}));
{{/eq}}
{{#eq formitem.valueOP "NOTEQ"}}
this.getEsCond().mustNot(QueryBuilders.termQuery("{{lowerCase field.name}}", {{camelCase field.codeName}}{{formitem.valueOP}}));
{{/eq}}
{{#eq formitem.valueOP "GT"}}
this.getEsCond().must(QueryBuilders.rangeQuery("{{lowerCase field.name}}").gt({{camelCase field.codeName}}{{formitem.valueOP}}));
{{/eq}}
{{#eq formitem.valueOP "GTANDEQ"}}
this.getEsCond().must(QueryBuilders.rangeQuery("{{lowerCase field.name}}").gte({{camelCase field.codeName}}{{formitem.valueOP}}));
{{/eq}}
{{#eq formitem.valueOP "LT"}}
this.getEsCond().must(QueryBuilders.rangeQuery("{{lowerCase field.name}}").lt({{camelCase field.codeName}}{{formitem.valueOP}}));
{{/eq}}
{{#eq formitem.valueOP "LTANDEQ"}}
this.getEsCond().must(QueryBuilders.rangeQuery("{{lowerCase field.name}}").lte({{camelCase field.codeName}}{{formitem.valueOP}}));
{{/eq}}
{{#eq formitem.valueOP "ISNOTNULL"}}
if(this.{{camelCase field.codeName}}{{formitem.valueOP}}.equals("1")){
this.getEsCond().mustNot(QueryBuilders.existsQuery("{{lowerCase field.name}}"));
}
{{/eq}}
{{#eq formitem.valueOP "ISNULL"}}
if(this.{{camelCase field.codeName}}{{formitem.valueOP}}.equals("1")){
this.getEsCond().must(QueryBuilders.existsQuery("{{lowerCase field.name}}"));
}
{{/eq}}
{{/if}}
}
return this;
}
{{/each}}
{{/each}}
/**
* 启用快速搜索
*/
public void setQuery(String query)
{
this.query=query;
if(!StringUtils.isEmpty(query)){
{{#each entity.quickSearchFields as |field|}}
{{#if @first}}
this.getSearchCond().and( wrapper ->
wrapper.like("{{lowerCase field.name}}", query)
{{else}}
.or().like("{{lowerCase field.name}}", query)
{{/if}}
{{#if @last}}
);
{{/if}}
{{/each}}
}
}
}
\ No newline at end of file
......@@ -10,6 +10,7 @@ import java.util.List;
public interface {{entity.codeName}}InheritMapping {
@Mappings({
@Mapping(target ="focusNull",ignore = true),
{{#each entity.indexRelation.lookup as |lookup|}}
@Mapping(source ="{{camelCase lookup.codeName}}",target = "{{camelCase lookup.refCodeName}}"),
{{/each}}
......@@ -17,6 +18,7 @@ public interface {{entity.codeName}}InheritMapping {
{{entity.indexRelation.relEntity.codeName}} to{{pascalCase entity.indexRelation.relEntity.codeName}}({{entity.codeName}} {{camelCase entity.codeName}});
@Mappings({
@Mapping(target ="focusNull",ignore = true),
{{#each entity.indexRelation.lookup as |lookup|}}
@Mapping(source ="{{camelCase lookup.refCodeName}}",target = "{{camelCase lookup.codeName}}"),
{{/each}}
......
package {{packageName}}.core.{{entity.module}}.service;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.Collection;
import java.math.BigInteger;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.scheduling.annotation.Async;
import com.alibaba.fastjson.JSONObject;
import org.springframework.cache.annotation.CacheEvict;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.dynamic.datasource.annotation.DS;
import cn.ibizlab.util.helper.CachedBeanCopier;
import {{packageName}}.core.{{entity.module}}.domain.{{entity.codeName}};
import {{packageName}}.core.{{entity.module}}.filter.{{entity.codeName}}SearchContext;
{{#dsName}}
@DS("{{entity.dataSource}}")
{{/dsName}}
public interface I{{entity.codeName}}Service {
{{entity.codeName}} get({{entity.codeName}} et);
default {{entity.codeName}} get({{entity.keyField.type.java}} key) {
return get(new {{entity.codeName}}().set{{pascalCase entity.keyField.codeName}}(key));
}
default List<{{entity.codeName}}> getByIds(Collection<{{entity.keyField.type.java}}> ids) {
List<{{entity.codeName}}> entities =new ArrayList();
ids.forEach(key -> entities.add(new {{entity.codeName}}().set{{pascalCase entity.keyField.codeName}}(key)));
return getByEntities(entities);
}
List<{{entity.codeName}}> getByEntities(List<{{entity.codeName}}> entities);
{{entity.codeName}} getDraft({{entity.codeName}} et);
boolean checkKey({{entity.codeName}} et);
boolean create({{entity.codeName}} et);
{{#enableEntityCache}}
@CacheEvict(value = "{{lowerCase entity.codeName}}", allEntries = true)
{{/enableEntityCache}}
boolean createBatch(List<{{entity.codeName}}> list);
boolean update({{entity.codeName}} et);
{{#enableEntityCache}}
@CacheEvict(value = "{{lowerCase entity.codeName}}", allEntries = true)
{{/enableEntityCache}}
boolean updateBatch(List<{{entity.codeName}}> list);
boolean save({{entity.codeName}} et);
{{#enableEntityCache}}
@CacheEvict(value = "{{lowerCase entity.codeName}}", allEntries = true)
{{/enableEntityCache}}
boolean saveBatch(List<{{entity.codeName}}> list);
default boolean remove({{entity.keyField.type.java}} key) {
return remove(new {{entity.codeName}}().set{{pascalCase entity.keyField.codeName}}(key));
}
boolean remove({{entity.codeName}} et);
{{#enableEntityCache}}
@CacheEvict(value = "{{lowerCase entity.codeName}}", allEntries = true)
{{/enableEntityCache}}
boolean removeBatch(Collection<{{entity.keyField.type.java}}> ids);
{{#each entity.extActions}}
{{entity.codeName}} {{camelCase codeName}}({{entity.codeName}} et);
boolean {{camelCase codeName}}Batch(List<{{entity.codeName}}> list);
{{/each}}
{{#entity.dataSets}}
Page<{{#if enableGroup}}Map{{else}}{{entity.codeName}}{{/if}}> search{{pascalCase codeName}}({{entity.codeName}}SearchContext context);
List<{{#if enableGroup}}Map{{else}}{{entity.codeName}}{{/if}}> list{{pascalCase codeName}}({{entity.codeName}}SearchContext context);
{{/entity.dataSets}}
{{#entity.references}}
List<{{entity.codeName}}> selectBy{{pascalCase fkField.codeName}}({{fkField.type.java}} {{camelCase fkField.codeName}});
{{#enableEntityCache}}
@CacheEvict(value = "{{lowerCase entity.codeName}}", allEntries = true)
{{/enableEntityCache}}
boolean removeBy{{pascalCase fkField.codeName}}({{fkField.type.java}} {{camelCase fkField.codeName}});
{{#enableEntityCache}}
@CacheEvict(value = "{{lowerCase entity.codeName}}", allEntries = true)
{{/enableEntityCache}}
boolean resetBy{{pascalCase fkField.codeName}}({{fkField.type.java}} {{camelCase fkField.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);
{{/entity.references}}
}
\ No newline at end of file
......@@ -66,7 +66,7 @@ public class {{entity.codeName}}ServiceImpl extends ServiceImpl<{{entity.codeNam
{{#if entity.indexSubDE}}
@Autowired
@Lazy
protected {{packageName}}.core.{{entity.module}}.mapping.{{entity.codeName}}InheritMapping {{camelCase codeName}}InheritMapping;
protected {{packageName}}.core.{{entity.module}}.mapping.{{entity.codeName}}InheritMapping {{camelCase entity.codeName}}InheritMapping;
{{/if}}
protected int batchSize = 500;
......@@ -115,8 +115,8 @@ public class {{entity.codeName}}ServiceImpl extends ServiceImpl<{{entity.codeNam
{{/entity.hasReferences}}
{{#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}} = {{entity.codeName}}InheritMapping.to{{pascalCase entity.indexRelation.entityCodeName}}(et);
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);
{{#if entity.indexRelation.indexTypePSDEField}}
{{camelCase entity.indexRelation.entityCodeName}}.set("{{lowerCase entity.indexRelation.indexTypePSDEField.codeName}}","{{entity.indexRelation.typeValue}}");
{{/if}}
......@@ -175,7 +175,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}} = {{entity.codeName}}InheritMapping.to{{pascalCase entity.indexRelation.entityCodeName}}(et);
{{packageName}}.core.{{entity.indexRelation.module}}.domain.{{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}}
......@@ -278,7 +278,7 @@ public class {{entity.codeName}}ServiceImpl extends ServiceImpl<{{entity.codeNam
{{/unless}}
{{/entity.nesteds}}
{{#entity.isIndexSubDE}}
{{camelCase entity.indexRelation.entityCodeName}}Service.remove({{entity.codeName}}InheritMapping.to{{pascalCase entity.indexRelation.entityCodeName}}(et));
{{camelCase entity.indexRelation.entityCodeName}}Service.remove({{camelCase entity.codeName}}InheritMapping.to{{pascalCase entity.indexRelation.entityCodeName}}(et));
{{/entity.isIndexSubDE}}
......
package {{packageName}}.core.{{entity.module}}.service.impl;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.Map;
import java.util.HashSet;
import java.util.HashMap;
import java.util.Collection;
import java.util.Objects;
import java.util.Optional;
import java.math.BigInteger;
import lombok.extern.slf4j.Slf4j;
import cn.ibizlab.util.security.SpringContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.util.Assert;
import org.springframework.beans.factory.annotation.Value;
import cn.ibizlab.util.errors.BadRequestAlertException;
{{#system.enableGlobalTransaction}}
import io.seata.spring.annotation.GlobalTransactional;
{{/system.enableGlobalTransaction}}
import org.springframework.transaction.annotation.Transactional;
import org.springframework.context.annotation.Lazy;
import {{packageName}}.core.{{entity.module}}.domain.{{entity.codeName}};
import {{packageName}}.core.{{entity.module}}.filter.{{entity.codeName}}SearchContext;
import {{packageName}}.core.{{entity.module}}.service.I{{entity.codeName}}Service;
import cn.ibizlab.util.helper.CachedBeanCopier;
import cn.ibizlab.util.helper.DEFieldCacheMap;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
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.logicName}}] 服务对象接口实现
*/
@Slf4j
@Service("{{entity.codeName}}ServiceImpl")
public class {{entity.codeName}}ServiceImpl implements I{{entity.codeName}}Service {
protected I{{entity.codeName}}Service {{camelCase entity.codeName}}Service = SpringContextHolder.getBean(this.getClass());
{{#entity.relEntities}}
{{#neq storage "NONE"}}
@Autowired
@Lazy
protected {{packageName}}.core.{{module}}.service.I{{codeName}}Service {{camelCase codeName}}Service;
{{/neq}}
{{/entity.relEntities}}
{{#if entity.indexSubDE}}
@Autowired
@Lazy
protected {{packageName}}.core.{{entity.module}}.mapping.{{entity.codeName}}InheritMapping {{camelCase entity.codeName}}InheritMapping;
{{/if}}
protected int batchSize = 500;
public {{entity.codeName}} get({{entity.codeName}} et) {
return et;
}
public List<{{entity.codeName}}> getByEntities(List<{{entity.codeName}}> entities) {
return null;
}
{{#entity.hasReferences}}
public void fillParentData({{entity.codeName}} et) {
}
{{/entity.hasReferences}}
public {{entity.codeName}} getDraft({{entity.codeName}} et) {
{{#entity.hasReferences}}
fillParentData(et);
{{/entity.hasReferences}}
return et;
}
public boolean checkKey({{entity.codeName}} et) {
return false;
}
@Override
{{#eq entity.actions.create.transactionMode "GLOBAL"}}@GlobalTransactional{{/eq}}{{#eq entity.actions.create.transactionMode "DEFAULT"}}@Transactional{{/eq}}
public boolean create({{entity.codeName}} et) {
return true;
}
{{#eq entity.actions.create.transactionMode "GLOBAL"}}@GlobalTransactional{{/eq}}{{#eq entity.actions.create.transactionMode "DEFAULT"}}@Transactional{{/eq}}
public boolean createBatch(List<{{entity.codeName}}> list) {
return true;
}
{{#eq entity.actions.update.transactionMode "GLOBAL"}}@GlobalTransactional{{/eq}}{{#eq entity.actions.update.transactionMode "DEFAULT"}}@Transactional{{/eq}}
public boolean update({{entity.codeName}} et) {
{{#entity.hasReferences}}
fillParentData(et);
{{/entity.hasReferences}}
return true;
}
{{#eq entity.actions.update.transactionMode "GLOBAL"}}@GlobalTransactional{{/eq}}{{#eq entity.actions.update.transactionMode "DEFAULT"}}@Transactional{{/eq}}
public boolean updateBatch(List<{{entity.codeName}}> list) {
return true;
}
{{#eq entity.actions.save.transactionMode "GLOBAL"}}@GlobalTransactional{{/eq}}{{#eq entity.actions.save.transactionMode "DEFAULT"}}@Transactional{{/eq}}
public boolean save({{entity.codeName}} et) {
if(checkKey(et))
return {{camelCase entity.codeName}}Service.update(et);
else
return {{camelCase entity.codeName}}Service.create(et);
}
{{#eq entity.actions.save.transactionMode "GLOBAL"}}@GlobalTransactional{{/eq}}{{#eq entity.actions.save.transactionMode "DEFAULT"}}@Transactional{{/eq}}
public boolean saveBatch(List<{{entity.codeName}}> list) {
List<{{entity.codeName}}> rt=this.getByEntities(list);
Set<Serializable> keys=new HashSet<>();
rt.forEach(et->{
Serializable key = et.get{{pascalCase entity.keyField.codeName}}();
if(!ObjectUtils.isEmpty(key))
keys.add(key);
});
List<{{entity.codeName}}> _create=new ArrayList<>();
List<{{entity.codeName}}> _update=new ArrayList<>();
list.forEach(et-> {
Serializable key = et.get{{pascalCase entity.keyField.codeName}}();
if(keys.contains(key))
_update.add(et);
else
_create.add(et);
});
List rtList=new ArrayList<>();
if(_update.size()>0 && (!{{camelCase entity.codeName}}Service.updateBatch(_update)))
return false;
if(_create.size()>0 && (!{{camelCase entity.codeName}}Service.createBatch(_create)))
return false;
return true;
}
{{#eq entity.actions.remove.transactionMode "GLOBAL"}}@GlobalTransactional{{/eq}}{{#eq entity.actions.remove.transactionMode "DEFAULT"}}@Transactional{{/eq}}
public boolean remove({{entity.codeName}} et) {
return false ;
}
{{#eq entity.actions.remove.transactionMode "GLOBAL"}}@GlobalTransactional{{/eq}}{{#eq entity.actions.remove.transactionMode "DEFAULT"}}@Transactional{{/eq}}
public boolean removeBatch(Collection<{{entity.keyField.type.java}}> ids) {
return false;
}
{{#entity.extActions}}
{{#eq transactionMode "GLOBAL"}}@GlobalTransactional{{/eq}}{{#eq transactionMode "DEFAULT"}}@Transactional{{/eq}}
public {{entity.codeName}} {{camelCase codeName}}({{entity.codeName}} et) {
return et;
}
{{#eq transactionMode "GLOBAL"}}@GlobalTransactional{{/eq}}{{#eq transactionMode "DEFAULT"}}@Transactional{{/eq}}
public boolean {{camelCase codeName}}Batch(List<{{entity.codeName}}> list) {
return false;
}
{{/entity.extActions}}
{{#entity.dataSets}}
public Page<{{#if enableGroup}}Map{{else}}{{entity.codeName}}{{/if}}> search{{pascalCase codeName}}({{entity.codeName}}SearchContext context) {
return null;
}
public List<{{#if enableGroup}}Map{{else}}{{entity.codeName}}{{/if}}> list{{pascalCase codeName}}({{entity.codeName}}SearchContext context) {
return null;
}
{{/entity.dataSets}}
{{#entity.references}}
public List<{{entity.codeName}}> selectBy{{pascalCase fkField.codeName}}({{fkField.type.java}} {{camelCase fkField.codeName}}) {
return null;
}
public boolean removeBy{{pascalCase fkField.codeName}}({{fkField.type.java}} {{camelCase fkField.codeName}}) {
return false;
}
public boolean resetBy{{pascalCase fkField.codeName}}({{fkField.type.java}} {{camelCase fkField.codeName}}) {
return false;
}
public boolean saveBy{{pascalCase fkField.codeName}}({{fkField.type.java}} {{camelCase fkField.codeName}},List<{{entity.codeName}}> list) {
return false;
}
{{/entity.references}}
}
\ No newline at end of file
......@@ -57,12 +57,12 @@ public class {{apiEntity.codeName}}Resource {
{{#each apiEntity.methods}}
@ApiOperation(value = "{{apiEntity.entity.logicName}}", tags = {"{{apiEntity.entity.logicName}}" }, notes = "{{apiEntity.entity.logicName}}")
@RequestMapping(method = RequestMethod.{{requestMethod}}, value = "{{requestPath}}")
public ResponseEntity {{camelCase name}}{{#each pathVariables}}{{#if @first}}By{{else}}And{{/if}}{{pascalCase name}}{{/each}}({{#each pathVariables}}{{#unless @first}}, {{/unless}}@PathVariable("{{camelCase name}}") {{type.java}} {{camelCase name}}{{/each}}{{#if body}}{{#if pathVariables}}, {{/if}}@Validated @RequestBody {{body}} {{camelCase body}}{{/if}}) {
public ResponseEntity {{camelCase methodName}}({{#each pathVariables}}{{#unless @first}}, {{/unless}}@PathVariable("{{camelCase name}}") {{type.java}} {{camelCase name}}{{/each}}{{#if body}}{{#if pathVariables}}, {{/if}}@Validated @RequestBody {{body}} {{camelCase body}}{{/if}}) {
{{!行为}}
{{#eq methodType "DEACTION"}}
{{!行为参数准备}}
{{#eq input.type "DTO"}}
{{apiEntity.entity.codeName}} {{camelCase apiEntity.entity.codeName}} = {{camelCase input.psDEMethodDTO.name}}Mapping.toDomain({{camelCase body}});
{{apiEntity.entity.codeName}} {{camelCase apiEntity.entity.codeName}} = {{camelCase input.pSDEMethodDTO.name}}Mapping.toDomain({{camelCase body}});
{{#each pathVariables}}
{{#if @last}}
{{camelCase apiEntity.entity.codeName}}.set{{pascalCase name}}({{camelCase name}});
......@@ -80,7 +80,7 @@ public class {{apiEntity.codeName}}Resource {
{{/eq}}
{{!返回处理}}
{{#eq return.type "DTO"}}
return ResponseEntity.status(HttpStatus.OK).body({{camelCase return.psDEMethodDTO.name}}Mapping.toDto({{camelCase apiEntity.entity.codeName}}));
return ResponseEntity.status(HttpStatus.OK).body({{camelCase return.pSDEMethodDTO.name}}Mapping.toDto({{camelCase apiEntity.entity.codeName}}));
{{/eq}}
{{#eq return.type "SIMPLE"}}
return ResponseEntity.status(HttpStatus.OK).body(0);
......@@ -99,8 +99,8 @@ public class {{apiEntity.codeName}}Resource {
{{camelCase body}}.set{{pascalCase name}}EQ({{camelCase name}});
{{/if}}
{{/each}}
Page<{{apiEntity.entity.codeName}}> domains = {{camelCase apiEntity.entity.codeName}}Service.search{{pSDEDataSet.codeName}}({{camelCase body}}) ;
List<{{return.psDEMethodDTO.name}}> list = {{camelCase return.psDEMethodDTO.name}}Mapping.toDto(domains.getContent());
Page<{{apiEntity.entity.codeName}}> domains = {{camelCase apiEntity.entity.codeName}}Service.search{{pascalCase pSDEDataSet.codeName}}({{camelCase body}}) ;
List<{{return.pSDEMethodDTO.name}}> list = {{camelCase return.pSDEMethodDTO.name}}Mapping.toDto(domains.getContent());
return ResponseEntity.status(HttpStatus.OK)
.header("x-page", String.valueOf({{camelCase body}}.getPageable().getPageNumber()))
.header("x-per-page", String.valueOf({{camelCase body}}.getPageable().getPageSize()))
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册