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

ibizlab模板

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