提交 eac8730a 编写于 作者: sq3536's avatar sq3536

ibizlab模板

上级 8f51d4ca
......@@ -21,14 +21,14 @@ import org.springframework.beans.factory.annotation.Autowired;
@EnableDiscoveryClient
@Configuration
@EnableTransactionManagement
@EnableFeignClients(basePackages = {"{{packageName}}","cn.ibizlab.util"})
@EnableFeignClients(basePackages = {"cn.ibizlab.util","{{packageName}}"})
@SpringBootApplication(exclude = {
{{#unless system.enableMongo}}
org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration.class,
{{/unless}}
com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure.class
})
@ComponentScan(basePackages = {"{{packageName}}","cn.ibizlab.util"}
@ComponentScan(basePackages = {"cn.ibizlab.util","{{packageName}}"}
// ,excludeFilters = {
// @ComponentScan.Filter(type= org.springframework.context.annotation.FilterType.REGEX, pattern="{{packageName}}.xxx.rest.xxx"),
// }
......
package {{packageName}}.core.{{entity.module}}.service.impl;
package {{packageName}}.core.{{entity.module}}.client;
import java.io.Serializable;
import java.util.ArrayList;
......@@ -41,25 +41,19 @@ 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;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
/**
* 实体[{{entity.logicName}}] 服务对象接口实现
*/
@Slf4j
@Service("{{entity.codeName}}Service")
public class {{entity.codeName}}FeignClient implements {{entity.codeName}}Service {
public interface {{entity.codeName}}FeignClient {
default {{entity.codeName}} get({{entity.codeName}} et){
return get(et.get{{pascalCase entity.keyField.codeName}}());
}
@RequestMapping(method = RequestMethod.GET, value = "/{{pluralize entity.codeName}}/{key}")
{{entity.codeName}} get({{entity.keyField.type.java}} key) {
{{entity.codeName}} et = new {{entity.codeName}}();
et.set{{pascalCase entity.keyField.codeName}}(key);
return get(et);
}
{{entity.codeName}} get({{entity.keyField.type.java}} key);
default List<{{entity.codeName}}> getByIds(Collection<{{entity.keyField.type.java}}> ids) {
List<{{entity.codeName}}> entities =new ArrayList();
ids.forEach(key -> {
......
......@@ -91,19 +91,6 @@ public class {{entity.codeName}} extends EntityBase implements Serializable
{{#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}}
......
......@@ -118,10 +118,9 @@ public class {{entity.codeName}} extends EntityMP implements Serializable
/**
* 设置 [{{logicName}}]
*/
public {{entity.codeName}} set{{pascalCase codeName}}({{type.java}} {{camelCase codeName}}) {
public void set{{pascalCase codeName}}({{type.java}} {{camelCase codeName}}) {
this.{{camelCase codeName}} = {{camelCase codeName}};
this.modify("{{lowerCase name}}", {{camelCase codeName}});
return this;
}
{{/unless}}
{{/unless}}
......@@ -134,10 +133,9 @@ public class {{entity.codeName}} extends EntityMP implements Serializable
/**
* 设置 [{{entityLogicName}}]
*/
public {{entity.codeName}} set{{pascalCase codeName}}(List<{{entityCodeName}}> {{camelCase codeName}}) {
public void set{{pascalCase codeName}}(List<{{entityCodeName}}> {{camelCase codeName}}) {
this.{{camelCase codeName}} = {{camelCase codeName}};
this.modify("{{columnName}}", ({{camelCase codeName}}!=null)?{{camelCase codeName}}:(new ArrayList()));
return this;
}
{{/columnName}}
......@@ -156,7 +154,7 @@ public class {{entity.codeName}} extends EntityMP implements Serializable
/**
* 设置 [{{logicName}}]
*/
public {{entity.codeName}} set{{pascalCase entity.keyField.codeName}}({{entity.keyField.type.java}} {{camelCase entity.keyField.codeName}}) {
public void set{{pascalCase entity.keyField.codeName}}({{entity.keyField.type.java}} {{camelCase entity.keyField.codeName}}) {
this.{{camelCase entity.keyField.codeName}} = {{camelCase entity.keyField.codeName}};
if(!ObjectUtils.isEmpty({{camelCase entity.keyField.codeName}})) {
String [] args={{camelCase entity.keyField.codeName}}.split("\\|\\|");
......@@ -164,7 +162,6 @@ public class {{entity.codeName}} extends EntityMP implements Serializable
this.set("{{camelCase codeName}}", args[{{@index}}]);
{{/each}}
}
return this;
}
public {{entity.keyField.type.java}} get{{pascalCase entity.keyField.codeName}}() {
......
......@@ -96,10 +96,9 @@ public class {{entity.codeName}} extends EntityClient implements Serializable
/**
* 设置 [{{logicName}}]
*/
public {{entity.codeName}} set{{pascalCase codeName}}({{type.java}} {{camelCase codeName}}) {
public void set{{pascalCase codeName}}({{type.java}} {{camelCase codeName}}) {
this.{{camelCase codeName}} = {{camelCase codeName}};
this.modify("{{lowerCase codeName}}", {{camelCase codeName}});
return this;
}
{{/unless}}
{{/unless}}
......@@ -112,10 +111,9 @@ public class {{entity.codeName}} extends EntityClient implements Serializable
/**
* 设置 [{{entityLogicName}}]
*/
public {{entity.codeName}} set{{pascalCase codeName}}(List<{{entityCodeName}}> {{camelCase codeName}}) {
public void set{{pascalCase codeName}}(List<{{entityCodeName}}> {{camelCase codeName}}) {
this.{{camelCase codeName}} = {{camelCase codeName}};
this.modify("{{listCode}}", ({{camelCase codeName}}!=null)?{{camelCase codeName}}:(new ArrayList()));
return this;
}
{{/if}}
......
......@@ -59,7 +59,7 @@ import {{packageName}}.core.{{module}}.service.{{codeName}}Service;
@Service("{{entity.codeName}}Service")
public class {{entity.codeName}}ServiceBase extends ServiceImpl<{{entity.codeName}}Mapper,{{entity.codeName}}> implements {{entity.codeName}}Service {
protected {{entity.codeName}}Service getProxyService() {
protected {{entity.codeName}}Service getSelf() {
return SpringContextHolder.getBean(this.getClass());
}
......@@ -169,9 +169,9 @@ public class {{entity.codeName}}ServiceBase extends ServiceImpl<{{entity.codeNam
{{#if (or entity.actions.create.psDEActionLogics entity.isIndexSubDE)}}
for ({{entity.codeName}} et : list) {
{{#if entity.unionKeyMode}}
getProxyService().save(et);
getSelf().save(et);
{{else}}
getProxyService().create(et);
getSelf().create(et);
{{/if}}
}
{{else}}
......@@ -228,7 +228,7 @@ public class {{entity.codeName}}ServiceBase extends ServiceImpl<{{entity.codeNam
public boolean updateBatch(List<{{entity.codeName}}> list) {
{{#if (or entity.actions.update.psDEActionLogics entity.isIndexSubDE (not entity.keyField.phisicalDEField))}}
for ({{entity.codeName}} et : list) {
getProxyService().update(et);
getSelf().update(et);
}
{{else}}
{{#entity.hasReferences}}
......@@ -245,9 +245,9 @@ public class {{entity.codeName}}ServiceBase extends ServiceImpl<{{entity.codeNam
{{#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)==0)
return getProxyService().update(et);
return getSelf().update(et);
else
return getProxyService().create(et);
return getSelf().create(et);
}
{{#eq entity.actions.save.transactionMode "GLOBAL"}}@GlobalTransactional{{/eq}}{{#eq entity.actions.save.transactionMode "DEFAULT"}}@Transactional{{/eq}}
......@@ -269,9 +269,9 @@ public class {{entity.codeName}}ServiceBase extends ServiceImpl<{{entity.codeNam
_create.add(et);
});
List rtList=new ArrayList<>();
if(_update.size()>0 && (!getProxyService().updateBatch(_update)))
if(_update.size()>0 && (!getSelf().updateBatch(_update)))
return false;
if(_create.size()>0 && (!getProxyService().createBatch(_create)))
if(_create.size()>0 && (!getSelf().createBatch(_create)))
return false;
return true;
}
......@@ -320,7 +320,7 @@ public class {{entity.codeName}}ServiceBase extends ServiceImpl<{{entity.codeNam
public boolean removeBatch(Collection<{{entity.keyField.type.java}}> ids) {
{{#if (or entity.actions.update.psDEActionLogics entity.isIndexSubDE (not entity.keyField.phisicalDEField) entity.hasPSDERsMapping)}}
for ({{entity.keyField.type.java}} et : ids)
getProxyService().remove(et);
getSelf().remove(et);
{{else}}
if(!removeByIds(ids))
return false;
......@@ -390,11 +390,11 @@ public class {{entity.codeName}}ServiceBase extends ServiceImpl<{{entity.codeNam
else
_create.add(sub);
}
if(_update.size()>0 && (!getProxyService().updateBatch(_update)))
if(_update.size()>0 && (!getSelf().updateBatch(_update)))
return false;
if(_create.size()>0 && (!getProxyService().createBatch(_create)))
if(_create.size()>0 && (!getSelf().createBatch(_create)))
return false;
if(delIds.size()>0 && (!getProxyService().removeBatch(delIds)))
if(delIds.size()>0 && (!getSelf().removeBatch(delIds)))
return false;
return true;
}
......
......@@ -50,7 +50,9 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
@Service("{{entity.codeName}}Service")
public class {{entity.codeName}}ServiceBase implements {{entity.codeName}}Service {
protected {{entity.codeName}}Service {{camelCase entity.codeName}}Service = SpringContextHolder.getBean(this.getClass());
protected {{entity.codeName}}Service getSelf() {
return SpringContextHolder.getBean(this.getClass());
}
{{#entity.relEntities}}
{{#neq storage "NONE"}}
......@@ -120,9 +122,9 @@ public class {{entity.codeName}}ServiceBase implements {{entity.codeName}}Servic
{{#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)==0)
return {{camelCase entity.codeName}}Service.update(et);
return getSelf().update(et);
else
return {{camelCase entity.codeName}}Service.create(et);
return getSelf().create(et);
}
{{#eq entity.actions.save.transactionMode "GLOBAL"}}@GlobalTransactional{{/eq}}{{#eq entity.actions.save.transactionMode "DEFAULT"}}@Transactional{{/eq}}
......@@ -144,9 +146,9 @@ public class {{entity.codeName}}ServiceBase implements {{entity.codeName}}Servic
_create.add(et);
});
List rtList=new ArrayList<>();
if(_update.size()>0 && (!{{camelCase entity.codeName}}Service.updateBatch(_update)))
if(_update.size()>0 && (!getSelf().updateBatch(_update)))
return false;
if(_create.size()>0 && (!{{camelCase entity.codeName}}Service.createBatch(_create)))
if(_create.size()>0 && (!getSelf().createBatch(_create)))
return false;
return true;
}
......
......@@ -26,7 +26,7 @@ import java.util.List;
* mybatis全局配置类
*/
@Configuration
@MapperScan(value="{{packageName}}.core.*.mapper",nameGenerator = UniqueNameGenerator.class)
@MapperScan(value={"cn.ibizlab.util.mapper","{{packageName}}.core.*.mapper"},nameGenerator = UniqueNameGenerator.class)
public class MybatisConfiguration {
{{#eq system.saaSMode 4}}
@Autowired
......
......@@ -59,10 +59,9 @@ public class {{apiDto.codeName}} extends {{#eq apiDto.apiEntity.entity.psSubSysS
/**
* 设置 [{{logicName}}]
*/
public {{apiDto.codeName}} set{{pascalCase codeName}}({{javaType}} {{camelCase codeName}}) {
public void set{{pascalCase codeName}}({{javaType}} {{camelCase codeName}}) {
this.{{camelCase codeName}} = {{camelCase codeName}};
this.modify("{{lowerCase name}}", {{camelCase codeName}});
return this;
}
{{/unless}}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册