Commit d6a7578c authored by 刘凯's avatar 刘凯

增加remote remoteImpl等生成文件

parent 6eec11b4
......@@ -18,7 +18,7 @@ apply plugin: "idea"
apply plugin: "eclipse"
group = "cn.com.duiba"
version = "0.2.0"
version = "0.2.10"
sourceCompatibility = 1.8
targetCompatibility = 1.8
......
......@@ -42,30 +42,36 @@ public class MybatisGenerator {
} catch (SQLException e) {
throw new DuibaGeneratorException(e);
}
//生成dto文件
JavaDtoGenerator dtoGenerator = new JavaDtoGenerator(freemarkerService, tableEntity, config);
dtoGenerator.gen();
//生成entity文件
if(StringUtils.isNotBlank(config.getEntityPackage())) {
JavaEntityGenerator doGenerator = new JavaEntityGenerator(freemarkerService, tableEntity, config);
doGenerator.gen();
}
//生成dao文件
if(StringUtils.isNotBlank(config.getDaoPackage())) {
JavaDaoGenerator daoGenerator = new JavaDaoGenerator(freemarkerService, tableEntity, config);
daoGenerator.gen();
}
//生成daoImpl文件
if(StringUtils.isNotBlank(config.getDaoPackage())) {
JavaDaoImplGenerator daoImplGenerator = new JavaDaoImplGenerator(freemarkerService, tableEntity, config);
daoImplGenerator.gen();
}
//生成remote接口文件
JavaRemoteServiceInterfaceGenerator remoteInterfaceGenerator = new JavaRemoteServiceInterfaceGenerator(freemarkerService, tableEntity, config);
remoteInterfaceGenerator.gen();
//生成remoteImpl接口文件
if(StringUtils.isNotBlank(config.getRemoteImplLocation())) {
JavaRemoteServiceInterfaceImplGenerator remoteImplGenerator = new JavaRemoteServiceInterfaceImplGenerator(freemarkerService, tableEntity, config);
remoteImplGenerator.gen();
}
//生成Service接口文件
if(StringUtils.isNotBlank(config.getServiceLocation())) {
JavaServiceInterfaceGenerator serviceInterfaceGenerator = new JavaServiceInterfaceGenerator(freemarkerService, tableEntity, config);
serviceInterfaceGenerator.gen();
}
//生成ServiceImpl接口文件
if(StringUtils.isNotBlank(config.getServiceImplLocation())) {
JavaServiceInterfaceImplGenerator serviceImplGenerator = new JavaServiceInterfaceImplGenerator(freemarkerService, tableEntity, config);
serviceImplGenerator.gen();
}
//生成web层-Controller接口文件
// JavaControllerImplGenerator controllerGenerator = new JavaControllerImplGenerator(freemarkerService, tableEntity, config);
// controllerGenerator.gen();
......@@ -75,9 +81,25 @@ public class MybatisGenerator {
voImplGenerator.gen();
}
//生成xml文件
if(StringUtils.isNotBlank(config.getXmlLocation())){
SQLXmlGenerator sqlXmlGenerator = new SQLXmlGenerator(freemarkerService, tableEntity, config);
sqlXmlGenerator.gen();
}
if(StringUtils.isNotBlank(config.getApiModuleName())){
config.setModuleName(config.getApiModuleName());
}
//生成dto文件
if(StringUtils.isNotBlank(config.getDtoPackage())) {
JavaDtoGenerator dtoGenerator = new JavaDtoGenerator(freemarkerService, tableEntity, config);
dtoGenerator.gen();
}
//生成remoteImpl接口文件
if(StringUtils.isNotBlank(config.getRemotePackage())) {
JavaRemoteServiceInterfaceGenerator remoteInterfaceGenerator = new JavaRemoteServiceInterfaceGenerator(freemarkerService, tableEntity, config);
remoteInterfaceGenerator.gen();
}
}
private static void check(GeneratorConfig config) {
if (config == null){
......
......@@ -58,6 +58,11 @@ public class GeneratorConfig {
*/
private String moduleName;
/**
* 模块名称
*/
private String apiModuleName;
/**
* true:以测试用例执行生成代码的方式
*/
......@@ -135,14 +140,17 @@ public class GeneratorConfig {
if (StringUtils.isEmpty(serviceImplLocation)) {
throw new DuibaGeneratorException("serviceImplLocation is null");
}
if (StringUtils.isEmpty(voLocation)) {
throw new DuibaGeneratorException("voLocation is null");
}
if (StringUtils.isEmpty(controllerLocation)) {
throw new DuibaGeneratorException("controllerLocation is null");
}
public String getApiModuleName() {
return apiModuleName;
}
public void setApiModuleName(String apiModuleName) {
this.apiModuleName = apiModuleName;
}
public String getTablePrefix() {
......
......@@ -23,7 +23,7 @@ public class ${table.className}DaoImpl extends BaseDao implements ${table.classN
@Override
public Integer save(${table.className}Entity ${table.classname}Entity){
insert("save",${table.classname}Entity);
return ${table.classname}Entity.getId();
return ${table.classname}Entity.getId() > 0 ? 1 : 0;
}
<#if pk??>
......@@ -37,33 +37,39 @@ public class ${table.className}DaoImpl extends BaseDao implements ${table.classN
@Override
public void deleteBatchBy${pk.attrName}s(List<${pk.attrType}> ${pk.attrname}s){
return 0;
Map data = Maps.newHashMap();
data.put("${pk.attrName}s",${pk.attrname}s);
delete("deleteBatchBy${pk.attrName}",data);
}
@Override
public Integer updateBy${pk.attrName}(${table.className}Entity ${table.classname}Entity){
return 0;
return update("updateBy${pk.attrName}",${table.classname}Entity);
}
@Override
public ${table.className}Entity getBy${pk.attrName}(${pk.attrType} ${pk.attrname}){
return null;
return selectOne("getBy${pk.attrName}",${pk.attrname});
}
@Override
public List<${table.className}Entity> listBy${pk.attrName}s(List<${pk.attrType}> ${pk.attrname}s){
return null;
Map data = Maps.newHashMap();
data.put("${pk.attrname}s",${pk.attrname}s);
return selectList("listBy${pk.attrName}s",data);
}
</#if>
<#list uks?keys as key>
@Override
public ${table.className}Entity getBy${key}(<#assign idx=0><#list uks[key] as uk>${uk.attrType} ${uk.attrname}<#assign idx=idx+1><#if (idx<uks[key]?size)>,</#if></#list>){
//todo
return null;
}
@Override
public List<${table.className}Entity> listBy${key}s(<#assign idx=0><#list uks[key] as uk>List<${uk.attrType}> ${uk.attrname}s<#assign idx=idx+1><#if (idx<uks[key]?size)>,</#if></#list>){
//todo
return null;
}
......
......@@ -23,6 +23,7 @@ import java.io.Serializable;
</#if>
public class ${table.className}Dto implements Serializable {
private static final long serialVersionUID = 8065426618925769915L;
<#list columns as column>
......
......@@ -11,9 +11,9 @@ public interface Remote${table.className}Service {
Integer save(${table.className}Dto ${table.classname}Dto) throws BizException;
<#if pk??>
Integer deleteBy${pk.attrName}(${pk.attrType} ${pk.attrname}) throws BizException;
void deleteBy${pk.attrName}(${pk.attrType} ${pk.attrname}) throws BizException;
Integer deleteBatchBy${pk.attrName}s(List<${pk.attrType}> ${pk.attrname}s) throws BizException;
void deleteBatchBy${pk.attrName}s(List<${pk.attrType}> ${pk.attrname}s) throws BizException;
Integer updateBy${pk.attrName}(${table.className}Dto ${table.classname}Dto) throws BizException;
......
......@@ -25,13 +25,13 @@ public class Remote${table.className}ServiceImpl implements Remote${table.classN
<#if pk??>
@Override
public Integer deleteBy${pk.attrName}(${pk.attrType} ${pk.attrname}){
return ${table.classname}Service.deleteBy${pk.attrName}(${pk.attrname});
public void deleteBy${pk.attrName}(${pk.attrType} ${pk.attrname}){
${table.classname}Service.deleteBy${pk.attrName}(${pk.attrname});
}
@Override
public Integer deleteBatchBy${pk.attrName}s(List<${pk.attrType}> ${pk.attrname}s){
return ${table.classname}Service.deleteBatchBy${pk.attrName}(${pk.attrname}s);
public void deleteBatchBy${pk.attrName}s(List<${pk.attrType}> ${pk.attrname}s){
${table.classname}Service.deleteBatchBy${pk.attrName}(${pk.attrname}s);
}
@Override
......
......@@ -9,9 +9,9 @@ public interface ${table.className}Service {
Integer save(${table.className}Dto ${table.classname}Dto);
<#if pk??>
Integer deleteBy${pk.attrName}(${pk.attrType} ${pk.attrname});
void deleteBy${pk.attrName}(${pk.attrType} ${pk.attrname});
Integer deleteBatchBy${pk.attrName}s(List<${pk.attrType}> ${pk.attrname}s);
void deleteBatchBy${pk.attrName}s(List<${pk.attrType}> ${pk.attrname}s);
Integer updateBy${pk.attrName}(${table.className}Dto ${table.classname}Dto);
......
......@@ -29,13 +29,13 @@ public class ${table.className}ServiceImpl implements ${table.className}Service{
<#if pk??>
@Override
public Integer deleteBy${pk.attrName}(${pk.attrType} ${pk.attrname}){
return ${table.classname}Dao.deleteBy${pk.attrName}(${pk.attrname});
public void deleteBy${pk.attrName}(${pk.attrType} ${pk.attrname}){
${table.classname}Dao.deleteBy${pk.attrName}(${pk.attrname});
}
@Override
public Integer deleteBatchBy${pk.attrName}s(List<${pk.attrType}> ${pk.attrname}s){
return ${table.classname}Dao.deleteBatchBy${pk.attrName}(${pk.attrname}s);
public void deleteBatchBy${pk.attrName}s(List<${pk.attrType}> ${pk.attrname}s){
${table.classname}Dao.deleteBatchBy${pk.attrName}s(${pk.attrname}s);
}
@Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment